logback-spring.xml ゝ一世哀愁。 2022-11-28 10:54 2阅读 0赞 # 输出到控制台/输出到文件 # <?xml version="1.0" encoding="UTF-8"?> <configuration debug="false" scan="true" scanPeriod="5 seconds"> <!--指定日志输出路径 --> <property name="homedir" value="d:/applicationHome" /> <!--指定日志输出格式 --> <property name="pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger{36} - %msg%n" /> <!--输出到控制台 --> <appender name="console" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>${pattern}</pattern> </encoder> </appender> <!-- 在磁盘文件中输出日志 --> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <encoder> <pattern>${pattern}</pattern> </encoder> <!--当天日志文件输出的文件名--> <file>${homedir}/logs/log.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!--当天结束后,日志文件输出的文件名--> <fileNamePattern>${homedir}/logs/log.%d.log</fileNamePattern> <!--输出日志最大个数--> <maxHistory>30</maxHistory> </rollingPolicy> </appender> <!--把info级别的日志输出到 console和FILE--> <root level="info"> <appender-ref ref="console" /> <appender-ref ref="FILE" /> </root> <!-- 定义特殊日志输出,比如接口日志全部打印到 webservice.log 文件 --> <!-- 接口日志输出 --> <appender name="WEBSERVICE_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <encoder> <pattern>${pattern}</pattern> </encoder> <file>${homedir}/logs/webservice.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${homedir}/logs/webservice.%d.log</fileNamePattern> <maxHistory>30</maxHistory> </rollingPolicy> </appender> <!-- 接口日志 --> <logger name="zzc.learn.zookeeper.controller.WebServiceController" level="info" additivity="false"> <appender-ref ref="WEBSERVICE_FILE" /> <appender-ref ref="console" /> </logger> </configuration>
还没有评论,来说两句吧...