123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- <?xml version="1.0" encoding="UTF-8"?>
- <configuration scan="false">
- <contextName>cbkj</contextName>
- <!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
- <property name="LOG_PATH" value="/app/logs"/>
- <!--设置系统日志目录-->
- <property name="APPDIR" value="systemLogs"/>
- <!--设置日期格式 -->
- <timestamp key="bySecond" datePattern="yyyyMMdd'T'HHmmss"/>
- <!-- %m输出的信息,%p日志级别,%t线程名,%d日期,%c类的全名,,,, -->
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <!--<pattern>%d %p (%file:%line\)- %m%n</pattern>-->
- <!--格式化输出:%d:表示日期 %thread:表示线程名 %-5level:级别从左显示5个字符宽度 %msg:日志消息 %n:是换行符-->
- <pattern>1-%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger - %msg%n</pattern>
- <charset>utf-8</charset>
- </encoder>
- </appender>
- <!--
- 说明:
- 1、日志级别及文件
- 日志记录采用分级记录,级别与日志文件名相对应,不同级别的日志信息记录到不同的日志文件中
- 例如:error级别记录到log_error_xxx.log或log_error.log(该文件为当前记录的日志文件),而log_error_xxx.log为归档日志,
- 日志文件按日期记录,同一天内,若日志文件大小等于或大于2M,则按0、1、2...顺序分别命名
- 例如log-level-2013-12-21.0.log
- 其它级别的日志也是如此。
- 2、文件路径
- 若开发、测试用,在Eclipse中运行项目,则到Eclipse的安装路径查找logs文件夹,以相对路径../logs。
- 若部署到Tomcat下,则在Tomcat下的logs文件中
- 3、Appender
- FILEERROR对应error级别,文件名以log-error-xxx.log形式命名
- FILEWARN对应warn级别,文件名以log-warn-xxx.log形式命名
- FILEINFO对应info级别,文件名以log-info-xxx.log形式命名
- FILEDEBUG对应debug级别,文件名以log-debug-xxx.log形式命名
- CONSOLE将日志信息输出到控制上,为方便开发测试使用
- -->
- <!-- 日志记录器,日期滚动记录 -->
- <appender name="FILEERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <!-- 正在记录的日志文件的路径及文件名 -->
- <file>${LOG_PATH}/${APPDIR}/${bySecond}_error.log</file>
- <!-- 追加方式记录日志 -->
- <append>true</append>
- <!-- 日志记录器的滚动策略,按日期,按大小记录 -->
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <!-- 归档的日志文件的路径,例如今天是2013-12-21日志,当前写的日志文件路径为file节点指定,可以将此文件与file指定文件路径设置为不同路径,从而将当前日志文件或归档日志文件置不同的目录。
- 而2013-12-21的日志文件在由fileNamePattern指定。%d{yyyy-MM-dd}指定日期格式,%i指定索引 -->
- <fileNamePattern>${LOG_PATH}/${APPDIR}/error/log-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
- <!--日志文件保留天数-->
- <MaxHistory>30</MaxHistory>
- <!-- 除按日志记录之外,还配置了日志文件不能超过2M,若超过2M,日志文件会以索引0开始,命名日志文件,例如log-error-2013-12-21.0.log -->
- <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
- <maxFileSize>20MB</maxFileSize>
- </timeBasedFileNamingAndTriggeringPolicy>
- </rollingPolicy>
- <!-- 日志文件的格式 -->
- <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
- <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n</pattern>
- <charset>utf-8</charset>
- </encoder>
- <!-- 此日志文件只记录error级别的 -->
- <filter class="ch.qos.logback.classic.filter.LevelFilter">
- <level>error</level>
- <onMatch>ACCEPT</onMatch>
- <onMismatch>DENY</onMismatch>
- </filter>
- </appender>
- <!-- 日志记录器,日期滚动记录 1号接口 -->
- <appender name="one" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${LOG_PATH}/one/${bySecond}_interface1.log</file>
- <append>true</append>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>${LOG_PATH}/one/log-interface1-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
- <MaxHistory>10</MaxHistory>
- <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
- <maxFileSize>20MB</maxFileSize>
- </timeBasedFileNamingAndTriggeringPolicy>
- </rollingPolicy>
- <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
- <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n</pattern>
- <charset>utf-8</charset>
- </encoder>
- <filter class="ch.qos.logback.classic.filter.LevelFilter">
- <level>INFO</level>
- <onMatch>ACCEPT</onMatch>
- <onMismatch>DENY</onMismatch>
- </filter>
- </appender>
- <!-- 日志记录器,日期滚动记录 3号接口 -->
- <appender name="three" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${LOG_PATH}/three/${bySecond}_interface3.log</file>
- <append>true</append>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>${LOG_PATH}/three/log-interface3-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
- <MaxHistory>10</MaxHistory>
- <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
- <maxFileSize>20MB</maxFileSize>
- </timeBasedFileNamingAndTriggeringPolicy>
- </rollingPolicy>
- <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
- <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n</pattern>
- <charset>utf-8</charset>
- </encoder>
- <filter class="ch.qos.logback.classic.filter.LevelFilter">
- <level>INFO</level>
- <onMatch>ACCEPT</onMatch>
- <onMismatch>DENY</onMismatch>
- </filter>
- </appender>
- <!-- 日志记录器,日期滚动记录 4号接口 -->
- <appender name="four" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${LOG_PATH}/four/${bySecond}_interface4.log</file>
- <append>true</append>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>${LOG_PATH}/four/log-interface4-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
- <MaxHistory>10</MaxHistory>
- <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
- <maxFileSize>20MB</maxFileSize>
- </timeBasedFileNamingAndTriggeringPolicy>
- </rollingPolicy>
- <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
- <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n</pattern>
- <charset>utf-8</charset>
- </encoder>
- <filter class="ch.qos.logback.classic.filter.LevelFilter">
- <level>INFO</level>
- <onMatch>ACCEPT</onMatch>
- <onMismatch>DENY</onMismatch>
- </filter>
- </appender>
- <logger name="org.springframework.data.mybatis" level="DEBUG"/>
- <logger name="org.springframework.aop.aspectj" level="DEBUG"/>
- <logger name="org.apache.xerces" level="INFO"/>
- <logger name="javax.activation" level="WARN"/>
- <logger name="javax.mail" level="WARN"/>
- <logger name="javax.xml.bind" level="WARN"/>
- <logger name="ch.qos.logback" level="INFO"/>
- <logger name="com.codahale.metrics" level="WARN"/>
- <logger name="com.ryantenney" level="WARN"/>
- <logger name="com.sun" level="WARN"/>
- <logger name="com.zaxxer" level="WARN"/>
- <logger name="io.undertow" level="WARN"/>
- <logger name="net.sf.ehcache" level="WARN"/>
- <logger name="org.apache" level="WARN"/>
- <logger name="org.apache.catalina.startup.DigesterFactory" level="OFF"/>
- <logger name="org.bson" level="WARN"/>
- <logger name="org.hibernate.validator" level="WARN"/>
- <logger name="org.hibernate" level="WARN"/>
- <logger name="org.hibernate.ejb.HibernatePersistence" level="OFF"/>
- <logger name="org.springframework.web" level="INFO"/>
- <logger name="org.springframework.security" level="WARN"/>
- <logger name="org.springframework.cache" level="WARN"/>
- <logger name="org.thymeleaf" level="WARN"/>
- <logger name="sun.rmi" level="WARN"/>
- <logger name="sun.rmi.transport" level="WARN"/>
- <logger name="org.springframework.core" level="ERROR"/>
- <logger name="jdbc.connection" level="ERROR"/>
- <logger name="jdbc.resultset" level="ERROR"/>
- <logger name="jdbc.resultsettable" level="INFO"/>
- <logger name="jdbc.audit" level="ERROR"/>
- <!--<logger name="jdbc.sqltiming" level="ERROR"/>
- <logger name="jdbc.sqlonly" level="INFO"/>-->
- <!--生产环境使用注释内的配置-->
- <logger name="jdbc.sqltiming" level="INFO"/>
- <logger name="jdbc.sqlonly" level="OFF"/>
- <logger name="com.jiuzhekan.cbkj.mapper" level="DEBUG"/>
- <!-- 日志级别变更穿透 -->
- <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
- <resetJUL>true</resetJUL>
- </contextListener>
- <root level="INFO">
- <appender-ref ref="STDOUT"/>
- <appender-ref ref="FILEERROR"/>
- <!-- <appender-ref ref="FILEINFO"/>-->
- <!-- <appender-ref ref="FILEWARN"/>-->
- </root>
- <logger name="one" additivity="true">
- <appender-ref ref="one"/>
- </logger>
- <logger name="three" additivity="true">
- <appender-ref ref="three"/>
- </logger>
- <logger name="four" additivity="true">
- <appender-ref ref="four"/>
- </logger>
- </configuration>
|