|
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | +<Configuration status="WARN" monitorInterval="60"> |
| 3 | + <Properties> |
| 4 | + <Property name="LOG_HOME">../logs/</Property> |
| 5 | + <property name="APP_NAME" value="hi-log-log4j2" /> |
| 6 | + </Properties> |
| 7 | + |
| 8 | + <Appenders> |
| 9 | + <!-- 控制台输出 --> |
| 10 | + <Console name="Console" target="SYSTEM_OUT"> |
| 11 | + <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{96}[%line]: %msg%n"/> |
| 12 | + </Console> |
| 13 | + |
| 14 | + <!-- 按照每天生成日志文件 --> |
| 15 | + <RollingFile name="RollingInfoFile" fileName="${LOG_HOME}/info/${APP_NAME}.log" filePattern="${LOG_HOME}/info/${APP_NAME}_%d{yyyy-MM-dd}.%i.log"> |
| 16 | + <ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/> |
| 17 | + <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{96}[%line]: %msg%n"/> |
| 18 | + <Policies> |
| 19 | + <TimeBasedTriggeringPolicy/> |
| 20 | + <SizeBasedTriggeringPolicy size="128 MB"/> |
| 21 | + </Policies> |
| 22 | + </RollingFile> |
| 23 | + |
| 24 | + <RollingFile name="RollingErrorFile" fileName="${LOG_HOME}/info/${APP_NAME}.log" filePattern="${LOG_HOME}/info/${APP_NAME}_%d{yyyy-MM-dd}.%i.log"> |
| 25 | + <ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/> |
| 26 | + <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{96}[%line]: %msg%n"/> |
| 27 | + <Policies> |
| 28 | + <TimeBasedTriggeringPolicy/> |
| 29 | + <SizeBasedTriggeringPolicy size="128 MB"/> |
| 30 | + </Policies> |
| 31 | + </RollingFile> |
| 32 | + |
| 33 | + |
| 34 | + <!-- kafka appender --> |
| 35 | + <KafkaCustomize name="kafkaAppender" topic="app-log" zkServers="riot01.jthink.com:2181,riot02.jthink.com:2181,riot03.jthink.com:2181" |
| 36 | + mail="qianjc@unionpaysmart.com" rpc="none" app="${APP_NAME}" host="${hostName}"> |
| 37 | + <ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/> |
| 38 | + <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS};${APP_NAME};${hostName};%t;%-5level;%logger{96};%line;%msg%n"/> |
| 39 | + <Property name="bootstrap.servers">riot01.jthink.com:9092,riot02.jthink.com:9092,riot03.jthink.com:9092</Property> |
| 40 | + <Property name="acks">0</Property> |
| 41 | + <Property name="linger.ms">100</Property> |
| 42 | + <Property name="client.id">${APP_NAME}-${hostName}-log4j2</Property> |
| 43 | + </KafkaCustomize> |
| 44 | + </Appenders> |
| 45 | + |
| 46 | + <Loggers> |
| 47 | + <Root level="info"> |
| 48 | + <AppenderRef ref="Console"/> |
| 49 | + <AppenderRef ref="RollingInfoFile"/> |
| 50 | + <AppenderRef ref="RollingErrorFile"/> |
| 51 | + </Root> |
| 52 | + </Loggers> |
| 53 | +</Configuration> |
0 commit comments