I use log4j library for confirmation what is being send to db server by my EJB code. Everything was working fine till one day. It simply stopped logging. (it turned out that I’ve used somehow newer version of log4j in my project, I’ve changed pointer in Libraries in Netbeans).

  • I’ve created a new domain on my local server and deployed there my EJB webservice and log4j was logging fine:
    DEBUG java.sql.Connection - ooo Connection Opened
    DEBUG java.sql.PreparedStatement - ==>  Executing: select count(*) from network_elements
    DEBUG java.sql.PreparedStatement - ==> Parameters:
    DEBUG java.sql.ResultSet - <==    Columns: 1
    DEBUG java.sql.ResultSet - <==        Row: 0
    DEBUG java.sql.Connection - xxx Connection Closed
  • I’ve noticed it should be a domain/server problem and started googling for this issue and found a solution:
  • Log4j
  • Glassfish v3 and later + log4j seem to have some sort of classloader problem: log4j library is loaded by different classloaders and this causes some kind of conflict if you deploy log4j with your application. The only solution I could find was to copy┬álog4j-1.2.16.jar to <glassfish-installation>/glassfish/domains/domain1/lib. So please do this before proceding.
  • it comes from Hibernate JPA 2.0 on glassfish v3 with Netbeans IDE setup tutorial another amazing blog :)

My Log4j knowledge is very basic, I just use a given example of configuration: sort1.properties from examples directory from log4j librabry:

log4j.rootLogger=DEBUG, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

log4j.appender.stdout.layout.ConversionPattern=%5p %c - %m%n
  • Dave

    I found that logging stopped after I started using HSQLDB. I eventually discovered the advice to set system property hsqldb.reconfig_logging=false.