Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring日志记录到文件(log4j)_Spring_Logging_Log4j - Fatal编程技术网

Spring日志记录到文件(log4j)

Spring日志记录到文件(log4j),spring,logging,log4j,Spring,Logging,Log4j,我有一个Maven项目,我想在其中启用Spring日志记录到日志文件。我使用的日志系统是log4j。我已将其放在log4j.properties文件中,但这还不够: log4j.category.org.springframework=ALL 我想将日志保存到现有的appender中,或者保存到一个单独的文件中 对于单独的文件,使用appender文件定义根记录器,如下所示: # Define the root logger with appender file log4j.rootLogge

我有一个Maven项目,我想在其中启用Spring日志记录到日志文件。我使用的日志系统是log4j。我已将其放在log4j.properties文件中,但这还不够:

log4j.category.org.springframework=ALL

我想将日志保存到现有的appender中,或者保存到一个单独的文件中

对于单独的文件,使用appender文件定义根记录器,如下所示:

# Define the root logger with appender file
log4j.rootLogger = info, FILE  

# Define the file appender
log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender

# Set the name of the file
log4j.appender.FILE.File=/your/path/to/logfile/logfilename.log

# Set the immediate flush to true (default)
log4j.appender.FILE.ImmediateFlush=true

# Set the threshold to debug mode
log4j.appender.FILE.Threshold=info

# Set the append to false, should not overwrite
log4j.appender.FILE.Append=true

# Set the DatePattern
log4j.appender.FILE.DatePattern='.' yyyy-MM-dd

# Define the layout for file appender
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.conversionPattern=[%d{dd/MM/yyyy HH:mm:ss} %-5p %c{1}:%L] Method:- %M : %m%n
编辑

根据在属性文件中使用此设置日志级别


但它将如何恢复它应该记录春天?我在log4j属性文件中已经有几个appender,但是当我为spring添加行时,它没有出现在日志中。
 log4j.level.org.springframework.web: info