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的控制台的输出