• 实时电商数仓(二)之数据采集(一)搭建日志采集系统的集群(一)模拟日志生成器的使用


    1 拷贝日志生成jar包到虚拟机的某个目录

    2 修改application.properties

    # 外部配置打开
    # logging.config=./logback.xml
    #业务日期
    mock.date=2020-05-16
    
    #模拟数据发送模式
    mock.type=http
    #http模式下,发送的地址
    mock.url=http://192.168.41.133:80/applog
    
    #启动次数
    mock.startup.count=10000
    #设备最大值
    mock.max.mid=50
    #会员最大值
    mock.max.uid=500
    #商品最大值
    mock.max.sku-id=10
    #页面平均访问时间
    mock.page.during-time-ms=20000
    #错误概率 百分比
    mock.error.rate=3
    #每条日志发送延迟 ms
    mock.log.sleep=10
    #商品详情来源  用户查询,商品推广,智能推荐, 促销活动
    mock.detail.source-type-rate=40:25:15:20

    mock.url 指的是后端服务器的地址(或者nginx服务器地址)

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <property name="LOG_HOME" value="/opt/applog/gmall2020" />
        <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
            <encoder>
                <pattern>%msg%n</pattern>
            </encoder>
        </appender>
    
        <appender name="rollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <file>${LOG_HOME}/app.log</file>
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                <fileNamePattern>${LOG_HOME}/app.%d{yyyy-MM-dd}.log</fileNamePattern>
            </rollingPolicy>
            <encoder>
                <pattern>%msg%n</pattern>
            </encoder>
        </appender>
    
    
        <appender name="errorRollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                <fileNamePattern>${LOG_HOME}/error.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
                <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                    <maxFileSize>200mb</maxFileSize>
                </timeBasedFileNamingAndTriggeringPolicy>
                <maxHistory>10</maxHistory>
            </rollingPolicy>
            <encoder>
                <pattern>%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
            </encoder>
            <filter class="ch.qos.logback.classic.filter.LevelFilter">
                <level>ERROR</level>
                <onMatch>ACCEPT</onMatch>
                <onMismatch>DENY</onMismatch>
            </filter>
        </appender>
    
    
    
        <appender name="async-rollingFile" class="ch.qos.logback.classic.AsyncAppender">
            <appender-ref ref="rollingFile" />
            <discardingThreshold>0</discardingThreshold>
            <queueSize>512</queueSize>
        </appender>
    
    
        <appender name="dao-rollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                <fileNamePattern>./logs/dao.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
                <timeBasedFileNamingAndTriggeringPolicy  class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                    <maxFileSize>500mb</maxFileSize>
                </timeBasedFileNamingAndTriggeringPolicy>
                <maxHistory>10</maxHistory>
            </rollingPolicy>
            <encoder>
                <pattern>%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
            </encoder>
        </appender>
        <appender name="async-daoRollingFile" class="ch.qos.logback.classic.AsyncAppender">
            <appender-ref ref="dao-rollingFile" />
            <includeCallerData>true</includeCallerData>
        </appender>
    
    
    
    
        <!-- 将某一个包下日志单独打印日志 -->
        <logger name="com.atgugu.gmall2020.mock.log.Mocker"
                level="INFO" additivity="true">
            <appender-ref ref="rollingFile" />
             <appender-ref ref="console" />
        </logger>
    
        <root level="error" additivity="true">
            <appender-ref ref="console" />
            <!-- <appender-ref ref="async-rollingFile" />  -->
        </root>
    </configuration>

    确保存在/opt/applog/gmall2020 以及有使用权限

    /opt/applog/gmall2020  存放日志位置

    3、使用模拟日志生成器的jar 运行

    java -jar gmall2020-mock-log-2020-04-01.jar

    本文来自博客园,作者:秋华,转载请注明原文链接:https://www.cnblogs.com/qiu-hua/p/13657339.html

  • 相关阅读:
    【js】实现输入框不允许输入某些特殊字符
    springboot集成druid实现数据源监控
    SpringBoot整合Druid并配置数据源监控
    SpringBoot集成Druid实现数据源管理和监控
    同一个catch字句中捕获多个java异常
    【JWT】JSON Web Token原理与实现
    行级锁实验:sql语句条件中的索引对锁的影响
    什么是乐观锁,什么是悲观锁,如何实现
    Linux命令与文件的查找which、wheris、locate、find
    vi编辑器永久设置行号、缩进
  • 原文地址:https://www.cnblogs.com/qiu-hua/p/13657339.html
Copyright © 2020-2023  润新知