1.log4j文件
- "1.0" encoding="UTF-8"?>
"5"> -
-
-
-
-
-
"LOG_PATTERN" value="%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n" /> -
-
"FILE_PATH" value="E:/logs/dev" /> -
"FILE_NAME" value="boot-log4j2" /> -
-
-
-
-
-
"Console" target="SYSTEM_OUT"> -
-
"${LOG_PATTERN}"/> -
-
"info" onMatch="ACCEPT" onMismatch="DENY"/> -
-
-
-
"Filelog" fileName="${FILE_PATH}/log4j2.log" append="true"> -
"${LOG_PATTERN}"/> -
-
-
-
"RollingFileInfo" fileName="${FILE_PATH}/info.log" filePattern="${FILE_PATH}/${FILE_NAME}-INFO-%d{yyyy-MM-dd}_%i.log.gz"> -
-
"info" onMatch="ACCEPT" onMismatch="DENY"/> -
"${LOG_PATTERN}"/> -
-
-
"1"/> -
"10MB"/> -
-
-
"15"/> -
-
-
-
"RollingFileWarn" fileName="${FILE_PATH}/warn.log" filePattern="${FILE_PATH}/${FILE_NAME}-WARN-%d{yyyy-MM-dd}_%i.log.gz"> -
-
"warn" onMatch="ACCEPT" onMismatch="DENY"/> -
"${LOG_PATTERN}"/> -
-
-
"1"/> -
"10MB"/> -
-
-
"15"/> -
-
-
-
"RollingFileError" fileName="${FILE_PATH}/error.log" filePattern="${FILE_PATH}/${FILE_NAME}-ERROR-%d{yyyy-MM-dd}_%i.log.gz"> -
-
"error" onMatch="ACCEPT" onMismatch="DENY"/> -
"${LOG_PATTERN}"/> -
-
-
"1"/> -
"10MB"/> -
-
-
"15"/> -
-
-
-
-
-
-
-
"org.mybatis" level="info" additivity="false"> -
"Console"/> -
-
-
-
"org.springframework" level="info" additivity="false"> -
"Console"/> -
-
"info"> -
"Console"/> -
"Filelog"/> -
"RollingFileInfo"/> -
"RollingFileWarn"/> -
"RollingFileError"/> -
-
-
2.yml配置
- logging:
- config: classpath:log4j2.xml
3.日志的级别
日志级别 OFF > FATAL > ERROR > WARN > INFO > DEBUG > TRACE > ALL
4. 日志的级别可以再配置文件配置
一般开发环境打DEBUG
生产环境打info