springboot 2.1.2log4j2日志文件未创建

时间:2019-02-13 11:43:35

标签: spring-boot log4j2

嗨,我是springboot的新手,我试图在文件中生成日志,但无法执行此操作,请为此提供帮助。 进入控制台文件的所有日志都无法确定,原因是应用程序启动时,百里香叶出现whitelabel错误500。创建了DB连接并创建了表,但未生成日志。 enter image description here log4j2.properties

status = trace
name= properties_configuration

# Give directory path where log files should get stored
property.basePath = C:/logs/

# ConsoleAppender will print logs on console
appender.console.type = Console
appender.console.name = consoleLogger
appender.console.target = SYSTEM_OUT
appender.console.layout.type = PatternLayout

# Specify the pattern of the logs
appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss.SSS} %level [%t] [%c] [%M] [%l] - %msg%n


# RollingFileAppender will print logs in file which can be rotated based on time or size
appender.rolling.type = RollingFile
appender.rolling.name = fileLogger
appender.rolling.fileName= ${basePath}app.log
appender.rolling.filePattern= ${basePath}app_%d{yyyyMMdd}.log.zip
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = %d{yyyy-MM-dd HH:mm:ss.SSS} %level [%t] [%c] [%M] [%l] - %msg%n
appender.rolling.policies.type = Policies

# Rotate log file each day and keep 30 days worth
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 1
appender.rolling.policies.time.modulate = true
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.delete.type = Delete
appender.rolling.strategy.delete.basePath = ${basePath}
appender.rolling.strategy.delete.maxDepth = 1
appender.rolling.strategy.delete.ifLastModified.type = IfLastModified
# Delete files older than 30 days
appender.rolling.strategy.delete.ifLastModified.age = 30d

# Mention package name here in place of example. Classes in this package or subpackages will use ConsoleAppender and RollingFileAppender for logging         
logger.name = com.optq.main.optimizeq
logger.com.optq.main.optimizeq.level = trace
logger.com.optq.main.optimizeq.additivity = trace
logger.com.optq.main.optimizeq.appenderRef.rolling.ref = fileLogger
logger.com.optq.main.optimizeq.appenderRef.console.ref = consoleLogger

# Configure root logger for logging error logs in classes which are in package other than above specified package
rootLogger.level = trace
rootLogger.additivity = trace
rootLogger.appenderRef.rolling.ref = fileLogger
rootLogger.appenderRef.console.ref = consoleLogger

0 个答案:

没有答案