Notes for logback log files

Source: Internet
Author: User

1. Supported jar packages

Logback-access-1.1.1.jar
Logback-classic-1.1.1.jar
Logback-core-1.1.1.jar

2. logback. xml file and web. xml file configuration

<? XML version = "1.0" encoding = "UTF-8"?> <Configuration scan = "true" scanperiod = "30 seconds"> <! -- Log Path --> <property name = "log_home" value = "/DD/log"/> <! -- Log file output --> <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> 10 MB </maxfilesize> </timebasedfilenamingandtriggeringpolicy> <! --> <! -- <Triggeringpolicy class = "ch. qoS. logback. core. rolling. sizebasedtriggeringpolicy "> <maxfilesize> 0.1 MB </maxfilesize> </triggeringpolicy> --> </rollingpolicy> <encoder> <pattern> % date % level [% thread] % logger. % class {0 }#% method [% file: % line] % MSG % n </pattern> <charset> GBK </charset> </encoder> </appender> <! -- Define console output --> <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 = "rollingfileout"/> </ logger> <! -- <Root level = "debug"> <appender-ref = "leleout"/> <appender-ref = "rollingfileout"/> </root> --> <root level = "debug"> <appender-ref = "consoleout"/> <appender-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. Notes

Comment out <appender-ref = "leleout"/> In logback. xml.
Catalina. Out is equivalent to the output of the Tomcat console.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.