以下是logback-local本地环境的日志配置和打印方式,以下内容仅供自己学习和使用!
<?xml version="1.0" encoding="UTF-8"?> <configuration scan="true" scanPeriod="120 seconds"> <property name="log.moduleName" value="temporary.construction"/> <property name="log.max.size" value="200MB" /> <appender name="console" class="ch.qos.logback.core.ConsoleAppender"> <encoder charset="UTF-8"> <pattern>%d %-5p %c-%L [%t] - %m%n</pattern> </encoder> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern>[%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{32}.%M\(%F:%L\) %thread %X{system} %X{app} %X{host}:%X{port}] %msg%n</pattern> </layout> </appender> <appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>logs/${log.moduleName}_log.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>logs/${log.moduleName}_log_%d{yyyy-MM-dd_HH}.log</fileNamePattern> <maxHistory>30</maxHistory> </rollingPolicy> <encoder charset="UTF-8"> <pattern>%d %-5p %c-%L [%t] - %m%n</pattern> </encoder> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern>[%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{32}.%M\(%F:%L\) %thread %X{system} %X{app} %X{host}:%X{port}] %msg%n</pattern> </layout> </appender> <logger name="org.apache.curator.framework" level="ERROR"/> <logger name="org.springframework" level="ERROR"/> <logger name="org.apache.zookeeper" level="ERROR"/> <logger name="com.netflix" level="ERROR"/> <logger name="springfox.documentation" level="ERROR"/> <logger name="com.baomidou" level="INFO"/> <logger name="org.apache.kafka" level="INFO"/> <logger name="org.apache.http" level="ERROR"/> <logger name="druid.sql" level="INFO"/> <root level="DEBUG"> <appender-ref ref="console"/> <appender-ref ref="file"/> </root> </configuration>
完结!