越高包含的就越多,输出的信息也就越多
TRACE < DEBUG < INFO < WARN < ERROR < FATAL
#设置日志级别 logging: level: root: warn
1.首先需要把你yaml文件里面关于日志的配置去掉,避免冲突报错
#mybatis日志 #mybatis-plus: # configuration: # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #设置日志级别 #logging: # level: # root: warn
2.在resource目录下创建logback-spring.xml文件
logback }”来使用变量。 -->INFO ${CONSOLE_LOG_PATTERN} UTF-8 ${log.path}/log_info.log %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n UTF-8 ${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log 100MB 15 INFO ACCEPT DENY ${log.path}/log_warn.log %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n UTF-8 ${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log 100MB 15 warn ACCEPT DENY ${log.path}/log_error.log %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n UTF-8 ${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log 100MB 15 ERROR ACCEPT DENY
2.运行后指定路径就会生成.log文件
3.此时一般默认只有info信息写入,其他两个error和warn是没有信息的,有需要写入的话,方法如下:
log4j的使用
log4j.properties:
#Console Log log4j.rootLogger=INFO,console,debug,info,warn,error LOG_PATTERN=[%d{yyyy-MM-dd HH:mm:ss.SSS}] boot%X{context} - %5p [%t] --- %c{1}: %m%n #A1--Print log to Console log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.Threshold=DEBUG log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=${LOG_PATTERN} log4j.appender.info=org.apache.log4j.DailyRollingFileAppender log4j.appender.info.Threshold=INFO log4j.appender.info.File=${LOG_PATH}/${LOG_FILE}_info.log log4j.appender.info.DatePattern='.'yyyy-MM-dd log4j.appender.info.layout = org.apache.log4j.PatternLayout log4j.appender.info.layout.ConversionPattern=${LOG_PATTERN} log4j.appender.error=org.apache.log4j.DailyRollingFileAppender log4j.appender.error.Threshold=ERROR log4j.appender.error.File=${LOG_PATH}/${LOG_FILE}_error.log log4j.appender.error.DatePattern='.'yyyy-MM-dd log4j.appender.error.layout = org.apache.log4j.PatternLayout log4j.appender.error.layout.ConversionPattern=${LOG_PATTERN} log4j.appender.debug=org.apache.log4j.DailyRollingFileAppender log4j.appender.debug.Threshold=DEBUG log4j.appender.debug.File=${LOG_PATH}/${LOG_FILE}_debug.log log4j.appender.debug.DatePattern='.'yyyy-MM-dd log4j.appender.debug.layout = org.apache.log4j.PatternLayout log4j.appender.debug.layout.ConversionPattern=${LOG_PATTERN} log4j.appender.warn=org.apache.log4j.DailyRollingFileAppender log4j.appender.warn.Threshold=WARN log4j.appender.warn.File=${LOG_PATH}/${LOG_FILE}_warn.log log4j.appender.warn.DatePattern='.'yyyy-MM-dd log4j.appender.warn.layout = org.apache.log4j.PatternLayout log4j.appender.warn.layout.ConversionPattern=${LOG_PATTERN} #MQ发送记录 log4j.logger.mqLog=INFO,mqLog log4j.additivity.mqLog = false log4j.appender.mqLog=org.apache.log4j.DailyRollingFileAppender #log4j.appender.mqLog.Threshold=ERROR log4j.appender.mqLog.File=${LOG_PATH}/${LOG_FILE}_mqLog.log log4j.appender.mqLog.DatePattern='.'yyyy-MM-dd log4j.appender.mqLog.layout = org.apache.log4j.PatternLayout log4j.appender.mqLog.layout.ConversionPattern=${LOG_PATTERN}
上一篇:Node.js与npm版本比对