标签:dev minutes gprof files period pattern rac 单位 配置文件
<!-- https://mvnrepository.com/artifact/net.logstash.logback/logstash-logback-encoder --> <dependency> <groupId>net.logstash.logback</groupId> <artifactId>logstash-logback-encoder</artifactId> <version>5.2</version> </dependency>
<?xml version="1.0" encoding="UTF-8" ?> <!-- scan="true" 当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true。 --> <!-- scanPeriod="30 seconds" 设置每30秒自动扫描,若没有指定具体单位则以milliseconds为标准(单位:milliseconds, seconds, minutes or hours) --> <!-- debug="false"当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。--> <configuration scan="true" scanPeriod="30 seconds"> <!-- 上下文名称 --> <contextName>test</contextName> <!-- 存放日志文件路径 --> <property name="Log_Home" value="./logs"/> <!-- INFO级别 --> <appender name="FILE_INFO" class="ch.qos.logback.core.rolling.RollingFileAppender"> <File>${Log_Home}/info.log</File> <!-- 根据时间来制定滚动策略 --> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <FileNamePattern> ${Log_Home}/info.%d{yyyy-MM-dd}.%i.log.gz </FileNamePattern> <!-- 多久后自动清楚旧的日志文件,单位:月 --> <MaxHistory>12</MaxHistory> <TimeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <!-- 默认值是 10MB,文档最大值 --> <MaxFileSize>100MB</MaxFileSize> </TimeBasedFileNamingAndTriggeringPolicy> </rollingPolicy> <encoder> <Pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{50} - %msg%n</Pattern> </encoder> </appender> <!-- ch.qos.logback.core.ConsoleAppender 控制台输出 --> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 --> <pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{50} - %msg%n</pattern> </encoder> </appender> <!--上传日志到LogStash--> <appender name="LOGSTASH_uat" class="net.logstash.logback.appender.LogstashTcpSocketAppender"> <destination>172.16.4.141:5044</destination> <!-- encoder必须配置,有多种可选 --> <encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder"> <customFields>{"appName":"backend-sync"}</customFields> </encoder> <connectionStrategy> <roundRobin> <connectionTTL>5 minutes</connectionTTL> </roundRobin> </connectionStrategy> </appender> <!--上传日志到LogStash--> <appender name="LOGSTASH_dev" class="net.logstash.logback.appender.LogstashTcpSocketAppender"> <destination>172.16.4.141:5044</destination> <!-- encoder必须配置,有多种可选 --> <encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder"> <customFields>{"appName":"backend-sync"}</customFields> </encoder> <connectionStrategy> <roundRobin> <connectionTTL>5 minutes</connectionTTL> </roundRobin> </connectionStrategy> </appender> <springProfile name="uat,prod"> <!-- 当前日志总级别为TRACE、DEBUG、INFO、 WARN、ERROR、ALL和 OF --> <root level="WARN"> <appender-ref ref="STDOUT"/> <appender-ref ref="FILE_INFO"/> <appender-ref ref="LOGSTASH_uat"/> </root> <logger name="com.yungoal" level="INFO"> <appender-ref ref="STDOUT"/> <appender-ref ref="FILE_INFO"/> <appender-ref ref="LOGSTASH_uat"/> </logger> </springProfile> <springProfile name="dev,test"> <!-- 当前日志总级别为TRACE、DEBUG、INFO、 WARN、ERROR、ALL和 OF --> <root level="WARN"> <appender-ref ref="STDOUT"/> <appender-ref ref="FILE_INFO"/> <appender-ref ref="LOGSTASH_dev"/> </root> <logger name="com.yungoal" level="INFO"> <appender-ref ref="STDOUT"/> <appender-ref ref="FILE_INFO"/> <appender-ref ref="LOGSTASH_dev"/> </logger> </springProfile> </configuration>
标签:dev minutes gprof files period pattern rac 单位 配置文件
原文地址:https://www.cnblogs.com/songxingzhu/p/10060976.html