问题描述
我可以使日志进入控制台,但我似乎无法将其转到日志文件.这是我的properties文件.
log4j.rootLogger=DEBUG, LOG , stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p %d{d/MM/yy HH:mm:ss}:%m%n # log4j.appender.LOG.Threshold=INFO log4j.appender.LOG=org.apache.log4j.RollingFileAppender log4j.appender.LOG.File=C:\dev\harry\data\logs\core.log log4j.appender.LOG.layout=org.apache.log4j.PatternLayout log4j.appender.LOG.Append=true log4j.appender.LOG.layout.ConversionPattern=%5p %d{d/MM/yy HH:mm:ss}:%m%n # log4j.appender.LOG.Threshold=INFO
推荐答案
问题是您的单个\应该是\\.在大多数属性文件中都是如此.
其他推荐答案
文件路径中的\存在一些问题.该语法有点隐秘,但是登录到多个位置的方法是将命名的日志记录Appender附加到根记录器上.在此示例中,这是:
log4j.rootLogger=DEBUG, LOG , stdout
DEBUG是用于根记录器的记录级别(阈值过滤器).
LOG是记录appender的名称
stdout是第二个appender的名称
记录附录由
指定log4j.appender.{logging-appender-name}={some.log4j.appender.class} log4j.appender.{logging-appender-name}.{some-other-property}=...
其中{logging-appender-name}是您自己选择的名称(在这种情况下为log and stdout)和{some.log4j.appender.class}是许多log4j 记录appender class 例如 dailyrolllingfileappender 或 consoleappender .
其他推荐答案
我会添加: log4j.appender.log.threshold = all
我不确定默认值是什么.
问题描述
I can make the log to go the console but I cant seem to make it go to a log file. Here is my properties file.
log4j.rootLogger=DEBUG, LOG , stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p %d{d/MM/yy HH:mm:ss}:%m%n # log4j.appender.LOG.Threshold=INFO log4j.appender.LOG=org.apache.log4j.RollingFileAppender log4j.appender.LOG.File=C:\dev\harry\data\logs\core.log log4j.appender.LOG.layout=org.apache.log4j.PatternLayout log4j.appender.LOG.Append=true log4j.appender.LOG.layout.ConversionPattern=%5p %d{d/MM/yy HH:mm:ss}:%m%n # log4j.appender.LOG.Threshold=INFO
推荐答案
The problem is that your single \ should be \\. This is true in most properties files.
其他推荐答案
There are some issues with the \ in the file path that need to be fixed. The syntax is a bit cryptic but the way to log to multiple locations is to attach a named logging appender to the root logger. In this example this is:
log4j.rootLogger=DEBUG, LOG , stdout
DEBUG is a logging level (threshold filter) to use for the root logger.
LOG is the name of a logging appender
stdout is the name of a second appender
The logging appenders are specified by
log4j.appender.{logging-appender-name}={some.log4j.appender.class} log4j.appender.{logging-appender-name}.{some-other-property}=...
Where {logging-appender-name} is a name selected by yourself (in this case LOG and stdout) and {some.log4j.appender.class} is one of the many log4j logging appender classes such as DailyRollingFileAppender or ConsoleAppender.
其他推荐答案
I would have added: log4j.appender.LOG.Threshold=ALL
I'm not sure what the default is.