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

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

 

posted @ 2020-09-12 15:56  秋华  阅读(592)  评论(0编辑  收藏  举报