Authored by liangyi.chen@yoho.cn

添加日志组件

@@ -22,12 +22,6 @@ @@ -22,12 +22,6 @@
22 </dependency> 22 </dependency>
23 23
24 <dependency> 24 <dependency>
25 - <groupId>com.yoho.datasync.producer</groupId>  
26 - <artifactId>yoho-datasync-producer-common</artifactId>  
27 - </dependency>  
28 -  
29 -  
30 - <dependency>  
31 <groupId>com.alibaba.otter</groupId> 25 <groupId>com.alibaba.otter</groupId>
32 <artifactId>canal.client</artifactId> 26 <artifactId>canal.client</artifactId>
33 <version>${canal.version}</version> 27 <version>${canal.version}</version>
@@ -5,7 +5,6 @@ @@ -5,7 +5,6 @@
5 <packaging>pom</packaging> 5 <packaging>pom</packaging>
6 <modules> 6 <modules>
7 <module>starter</module> 7 <module>starter</module>
8 - <module>common</module>  
9 <module>canal</module> 8 <module>canal</module>
10 </modules> 9 </modules>
11 <parent> 10 <parent>
@@ -29,12 +28,6 @@ @@ -29,12 +28,6 @@
29 28
30 <dependencies> 29 <dependencies>
31 <dependency> 30 <dependency>
32 - <groupId>org.springframework.boot</groupId>  
33 - <artifactId>spring-boot-starter-data-jpa</artifactId>  
34 - </dependency>  
35 -  
36 -  
37 - <dependency>  
38 <groupId>org.projectlombok</groupId> 31 <groupId>org.projectlombok</groupId>
39 <artifactId>lombok</artifactId> 32 <artifactId>lombok</artifactId>
40 <version>1.14.4</version> 33 <version>1.14.4</version>
@@ -80,12 +73,6 @@ @@ -80,12 +73,6 @@
80 73
81 <dependency> 74 <dependency>
82 <groupId>com.yoho.datasync.producer</groupId> 75 <groupId>com.yoho.datasync.producer</groupId>
83 - <artifactId>yoho-datasync-producer-common</artifactId>  
84 - <version>${project.version}</version>  
85 - </dependency>  
86 -  
87 - <dependency>  
88 - <groupId>com.yoho.datasync.producer</groupId>  
89 <artifactId>yoho-datasync-producer-canal</artifactId> 76 <artifactId>yoho-datasync-producer-canal</artifactId>
90 <version>${project.version}</version> 77 <version>${project.version}</version>
91 </dependency> 78 </dependency>
@@ -6,7 +6,8 @@ canal: @@ -6,7 +6,8 @@ canal:
6 destination: "yhgrass" 6 destination: "yhgrass"
7 username: "" 7 username: ""
8 password: "" 8 password: ""
9 - filter: "yh_grass.grass_article_praise, yh_grass.grass_article_block, yh_grass.grass_article, yh_grass.grass_article_comment, yh_grass.grass_article_label, yh_grass.grass_article_product" 9 + filter: "yh_grass.grass_article_praise, yh_grass.grass_article_block, yh_grass.grass_article,
  10 + yh_grass.grass_article_comment, yh_grass.grass_article_label, yh_grass.grass_article_product"
10 fetchSize: "1000" 11 fetchSize: "1000"
11 zkAddress: "" 12 zkAddress: ""
12 13
@@ -18,7 +18,8 @@ rabbitmq: @@ -18,7 +18,8 @@ rabbitmq:
18 exchange: "yoho_datasync" 18 exchange: "yoho_datasync"
19 virtualHost: "/datasync" 19 virtualHost: "/datasync"
20 20
21 - 21 +logging:
  22 + config: classpath:logback-boot.xml
22 23
23 server: 24 server:
24 port: 8011 25 port: 8011
@@ -18,5 +18,8 @@ rabbitmq: @@ -18,5 +18,8 @@ rabbitmq:
18 exchange: "yoho_datasync" 18 exchange: "yoho_datasync"
19 virtualHost: "/datasync" 19 virtualHost: "/datasync"
20 20
  21 +logging:
  22 + config: classpath:logback-boot.xml
  23 +
21 server: 24 server:
22 port: 8011 25 port: 8011
1 spring: 1 spring:
2 profiles: 2 profiles:
3 - active: dev 3 + active: test
4 4
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +
  3 +<!-- 从高到地低 OFF 、 FATAL 、 ERROR 、 WARN 、 INFO 、 DEBUG 、 TRACE 、 ALL -->
  4 +<!-- 日志输出规则 根据当前ROOT 级别,日志输出时,级别高于root默认的级别时 会输出 -->
  5 +<!-- 以下 每个配置的 filter 是过滤掉输出文件里面,会出现高级别文件,依然出现低级别的日志信息,通过filter 过滤只记录本级别的日志-->
  6 +
  7 +
  8 +<!-- 属性描述 scan:性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。
  9 + debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
  10 +<configuration scan="true" scanPeriod="60 seconds" debug="false">
  11 + <!-- 日志最大的历史 7天 -->
  12 + <property name="maxHistory" value="7"/>
  13 + <!-- 日志最大的文件大小 10MB-->
  14 + <property name="maxFileSize" value="10MB"/>
  15 + <!-- 彩色日志 -->
  16 + <!-- 彩色日志依赖的渲染类 -->
  17 + <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
  18 + <conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
  19 + <conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
  20 + <!-- 彩色日志格式 -->
  21 + <property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
  22 +
  23 + <!-- ConsoleAppender 控制台输出日志 -->
  24 + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
  25 + <!-- 对日志进行格式化 -->
  26 + <encoder>
  27 + <Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
  28 + <!-- 设置字符集 -->
  29 + <charset>UTF-8</charset>
  30 + </encoder>
  31 + </appender>
  32 +
  33 + <!-- INFO级别日志 appender -->
  34 + <appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
  35 + <!-- 过滤器,过滤掉 TRACE 和 DEBUG 级别的日志 -->
  36 + <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
  37 + <level>INFO</level>
  38 + </filter>
  39 + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  40 + <!-- 按天回滚 daily -->
  41 + <fileNamePattern>/Data/logs/yoho-datasync-producer/%d{yyyy-MM-dd}/info-log.log</fileNamePattern>
  42 + <!-- 日志最大的保存天数 -->
  43 + <maxHistory>${maxHistory}</maxHistory>
  44 + </rollingPolicy>
  45 + <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
  46 + <maxFileSize>${maxFileSize}</maxFileSize>
  47 + </triggeringPolicy>
  48 + <encoder>
  49 + <Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
  50 + <!-- 设置字符集 -->
  51 + <charset>UTF-8</charset>
  52 + </encoder>
  53 + </appender>
  54 +
  55 + <!-- WARN级别日志 appender -->
  56 + <appender name="WARN" class="ch.qos.logback.core.rolling.RollingFileAppender">
  57 + <!-- 过滤器,过滤掉 TRACE 和 DEBUG 和 INFO 级别的日志 -->
  58 + <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
  59 + <level>WARN</level>
  60 + </filter>
  61 + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  62 + <!-- 按天回滚 daily -->
  63 + <fileNamePattern>/Data/logs/yoho-datasync-producer/%d{yyyy-MM-dd}/warn-log.log</fileNamePattern>
  64 + <!-- 日志最大的保存天数 -->
  65 + <maxHistory>${maxHistory}</maxHistory>
  66 + </rollingPolicy>
  67 + <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
  68 + <maxFileSize>${maxFileSize}</maxFileSize>
  69 + </triggeringPolicy>
  70 + <encoder>
  71 + <Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
  72 + <!-- 设置字符集 -->
  73 + <charset>UTF-8</charset>
  74 + </encoder>
  75 + </appender>
  76 +
  77 + <!-- root级别 DEBUG -->
  78 + <root level="INFO">
  79 + <!-- 控制台输出 -->
  80 + <appender-ref ref="STDOUT" />
  81 + <!-- 文件输出 -->
  82 + <appender-ref ref="INFO" />
  83 + <appender-ref ref="WARN" />
  84 + </root>
  85 +
  86 +</configuration>