logBack配置文件
程序员文章站
2022-07-03 20:06:55
...
依赖的包
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.11</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.1.11</version>
</dependency>
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!--appender console 表示会打印到tomcat catalina.log文件中-->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoding>UTF-8</encoding>
<encoder>
<pattern>[%d{HH:mm:ss.SSS}][%p][%c{40}][%t] %m%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>DEBUG</level>
</filter>
</appender>
<appender name="mmall" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--<File>d:/mmalllog/mmall.log</File>-->
<File>D:\work\server\tomcat\apache-tomcat-8.0.36\logs\mall\mmall.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>D:\work\server\tomcat\apache-tomcat-8.0.36\logs\mall\mmall.log.%d{yyyy-MM-dd}.gz</fileNamePattern>
<append>true</append>
<!--表示日志的记录保存天数-->
<maxHistory>10</maxHistory>
</rollingPolicy>
<encoder>
<pattern>[%d{HH:mm:ss.SSS}][%p][%c{40}][%t] %m%n</pattern>
</encoder>
</appender>
<!--归档错误日志-->
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>D:\work\server\tomcat\apache-tomcat-8.0.36\logs\mall\error.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>D:\work\server\tomcat\apache-tomcat-8.0.36\logs\mall\error.log.%d{yyyy-MM-dd}.gz</fileNamePattern>
<append>true</append>
<maxHistory>10</maxHistory>
</rollingPolicy>
<encoder>
<pattern>[%d{HH:mm:ss.SSS}][%p][%c{40}][%t] %m%n</pattern>
</encoder>
<!-- 过略其他级别,在Error中只显示ERROR级别的日志-->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!--additivity="false" 不让日志向上继承-->
<logger name="com.xuzhao.mmall" additivity="false" level="INFO" >
<appender-ref ref="mmall" />
<appender-ref ref="console"/>
</logger>
<!-- geelynote mybatis log 日志 -->
<logger name="com.xuzhao.mmall.dao" level="DEBUG"/>
<logger name="com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate" level="DEBUG" >
<appender-ref ref="console"/>
</logger>
<logger name="java.sql.Connection" level="DEBUG">
<appender-ref ref="console"/>
</logger>
<logger name="java.sql.Statement" level="DEBUG">
<appender-ref ref="console"/>
</logger>
<logger name="java.sql.PreparedStatement" level="DEBUG">
<appender-ref ref="console"/>
</logger>
<root level="DEBUG">
<appender-ref ref="console"/>
<appender-ref ref="error"/>
</root>
</configuration>
推荐阅读
-
Nginx的nginx.conf配置文件中文注释说明
-
linux vim 配置文件(高亮+自动缩进+行号+折叠+优化)
-
详解java配置文件的路径问题
-
ASP.NET core Web中使用appsettings.json配置文件的方法
-
Spring Boot异步输出Logback日志方法详解
-
Python使用ConfigParser模块操作配置文件的方法
-
phpmyadmin配置文件现在需要绝密的短密码(blowfish_secret)的2种解决方法
-
函数中使用require_once问题深入探讨 优雅的配置文件定义方法推荐
-
Nginx中运行PHP框架Laravel的配置文件分享
-
Nginx配置文件nginx.conf的常用配置方法