3

我正在尝试在我的 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 文件?

4

1 回答 1

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
于 2015-06-30T08:53:37.533 回答