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

  • 相关阅读:
    笨方法学python笔记
    Orchard CMS 单点解决方案(SSO)及两种身份认证模块的介绍
    Orchard Oauth身份认证模块,在原基础上支持百度,豆瓣,开心,QQ,人人,新浪,淘宝
    凉鞋
    第一天
    网络编程vc++、socket机制
    定时器
    界面的多语言切换/通过读取xml文件实现
    svn快速教程
    文件读写
  • 原文地址:https://www.cnblogs.com/simpledev/p/3863193.html
Copyright © 2020-2023  润新知