首页 > 代码库 > logback日志文件需要注意点
logback日志文件需要注意点
1.支持的jar包
logback-access-1.1.1.jar
logback-classic-1.1.1.jar
logback-core-1.1.1.jar
2.logback.xml文件,web.xml文件配置
<?xml version="1.0" encoding="UTF-8"?><configuration scan="true" scanPeriod="30 seconds"> <!--日志路径 --> <property name="LOG_HOME" value="/dd/log" /> <!-- 日志文件输出 --> <appender name="rollingFileOut" class="ch.qos.logback.core.rolling.RollingFileAppender"> <Encoding>UTF-8</Encoding> <prudent>true</prudent> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${LOG_HOME}/autoCon-%d{yyyy-MM-dd}.%i.log</fileNamePattern> <maxHistory>30</maxHistory> <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <maxFileSize>10MB</maxFileSize> </timeBasedFileNamingAndTriggeringPolicy><!-- --> <!-- <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> <MaxFileSize>0.1MB</MaxFileSize> </triggeringPolicy> --> </rollingPolicy> <encoder> <pattern>%date %level [%thread] %logger.%class{0}#%method [%file:%line] %msg%n</pattern> <charset>GBK</charset> </encoder> </appender> <!--定义控制台输出 --> <appender name="consoleOut" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%date %level [%thread] %logger.%class{0}#%method [%file:%line] %msg%n</pattern> </encoder> </appender> <logger name="App"> <appender-ref ref="rollingFileOut" /> </logger> <!-- <root level="debug"> <appender-ref ref="consoleOut" /> <appender-ref ref="rollingFileOut" /> </root> --> <root level="debug"> <appender-ref ref="consoleOut" /> <appender-ref ref="rollingFileOut" /> </root> </configuration>
<listener> <listener-class>com.autoyolConsole.util.listener.LogbackConfigListener</listener-class> </listener> <context-param> <param-name>logbackConfigLocation</param-name> <param-value>classpath:conf/logback.xml</param-value> </context-param>
3.需要注意点
logback.xml 里把这部分 <appender-ref ref="consoleOut" /> 注释掉就可以了
catalina.out 就相当于tomcat的控制台的输出
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。