log4jdbc没有写入日志文件

时间:2015-06-17 09:27:59

标签: jdbc connection-leaks log4jdbc

我正在尝试调试Struts应用程序中的连接泄漏并设置log4jdbc。我能够在控制台中看到log4jdbc日志,但我希望将jdbc连接打开/关闭事件写入日志文件。 下面是我的log4j.properties文件

  log4j.debug=true
! Log connection open/close events and connection number dump
 log4j.logger.jdbc.connection=INFO,connection
 log4j.additivity.jdbc.connection=false


! the appender used for the JDBC Connection open and close events
log4j.appender.connection=org.apache.log4j.RollingFileAppender
log4j.appender.connection.File=C:/dev/myworkspace/log/connection.log
log4j.appender.connection.layout=org.apache.log4j.PatternLayout
log4j.appender.connection.layout.ConversionPattern=%d{ISO8601} [%t] %-5p %c{1} - %m%n
log4j.appender.connection.MaxFileSize   = 2000KB
log4j.appender.connection.MaxBackupIndex    = 10

请告知我的属性文件有什么问题,因为日志没有写在connection.log文件中?

1 个答案:

答案 0 :(得分:0)

试试这个,

对于连接设置:

log4j.appender.connection=org.apache.log4j.RollingFileAppender
log4j.appender.connection.file=C:/dev/myworkspace/log/connection.log
log4j.appender.connection.maxFileSize=5MB
log4j.appender.connection.maxBackupIndex=5
log4j.appender.connection.append=true
log4j.appender.connection.layout=org.apache.log4j.PatternLayout
log4j.appender.connection.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

# Root logger option
log4j.rootLogger=INFO,file