paulwong

LOGBACK TUTORIA

https://github.com/abdulwaheed18/Slf4jTutorial 

http://stackoverflow.com/questions/10465301/tomcat-war-configure-logback-to-use-app-name-in-path

<configuration>

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
            </Pattern>
        </encoder>
    </appender>


    <appender name="FILE"
        class
="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>testFile7.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!-- daily rollover
            Once any of the below condition met, it will change the file name as below and compressed it. 
-->

            <fileNamePattern>logFile.%d{yyyy-MM-dd}.%i.log.zip
            </fileNamePattern>

            <!-- keep 30 days' worth of history -->
            <maxHistory>30</maxHistory>
            <!-- or whenever the file size reaches 10MB -->
            <timeBasedFileNamingAndTriggeringPolicy
                
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>10MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
        </rollingPolicy>

        <encoder>
            <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n
            </pattern>
        </encoder>
    </appender>

    <root level="INFO">
        <appender-ref ref="STDOUT" />
        <appender-ref ref="FILE" />
    </root>
</configuration>

posted on 2014-04-03 08:10 paulwong 阅读(507) 评论(0)  编辑  收藏 所属分类: J2EEJ2SELOGBACK


只有注册用户登录后才能发表评论。


网站导航: