我使用log4j在桌面应用程序中使用了日志,但是当我将该实用程序导出为可运行的jar时,运行此jar时不会创建日志文件。下面是我的log4j.properties文件。请告诉我我错过了什么。
# Log levels
log4j.rootLogger=DEBUG,CONSOLE,R
# Appender Configuration
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
# Pattern to output the caller's file name and line number
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
# Rolling File Appender
log4j.appender.R=org.apache.log4j.RollingFileAppender
# Path and file name to store the log file
log4j.appender.R.File=D:/myapp/mylog.log
log4j.appender.R.MaxFileSize=200KB
# Number of backup files
log4j.appender.R.MaxBackupIndex=2
# Layout for Rolling File Appender
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d - %c - %p - %m%n
答案 0 :(得分:0)
log4j.appender.R.File=C:\\loging.log
按照本教程了解有关log4j用法的更多信息:
http://www.mkyong.com/logging/log4j-log4j-properties-examples/