log4jdbc not writing to log files

665 views Asked by At

I am trying to debug connection leak in my Struts application and have set-up log4jdbc. I am able to see log4jdbc logs in console but I wish to have jdbc connection open/close events being written to a log file. Below is my log4j.properties file

  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

Please suggest what is wrong with my properties file as the logs are not written in connection.log file ?

1

There are 1 answers

1
Vigneshwaran On

Try out this,

For Connection settings:

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