3

How do I configure internal event monitoring in hsqldb? When I run my Java application, I get the following warnings:

log4j:WARN No appenders could be found for logger (HSQLDB2C7984E18B.org.hsqldb.persist.Logger).
log4j:WARN Please initialize the log4j system properly.

The documentation tells me log4j is not the only option, but it doesn't tell me how to configure my application. Can anyone point me to this documentation? Remember, I don't want to use log4j for hsqldb.

It bears mentioning that a 3rd-party jar I'm referencing requires log4j. Does hsqldb automatically detect that log4j is present and then attempt to use it? Or am I missing something fundamental about how logging works?

Isaac Sutherland
  • 3,082
  • 4
  • 28
  • 37

3 Answers3

1

Check out this link. It says

The logging facility hands off to Log4j if Log4j is found in the classpath, and otherwise will hand off to java.util.logging.

YWE
  • 2,849
  • 28
  • 42
  • In fact, I do have a log4j.properties file in my classpath, and I can fix the above warnings by specifying a rootLogger level, but the whole point is that I don't want to use log4j for hsqldb. – Isaac Sutherland Nov 23 '10 at 20:29
  • Thanks, YWE. Because my 3rd-part library uses log4j, the latter needs to be in the classpath. I describe how I fixed the WARN messages described above in my answer on this page. See http://stackoverflow.com/questions/4258849/override-log4j-properties for more general help on configuring log4j to avoid warnings. – Isaac Sutherland Dec 03 '10 at 19:51
0

The consequence of what the message indicates is that no logging for HSQLDB will take place because no appenders were found.

If you wish to suppress the message, add a line like the one below to the log4j.properties file:

log4j.logger.HSQLDB2C7984E18B.org.hsqldb.persist.Logger=FATAL

This will log only FATAL events, which wouldn't happen in normal operation.

You also state that you don't want to use log4j for HSQLDB. Software components that can use log4j leave the logging configuration (including level and where to log, etc.) to the log4j properties settings, which you can edit and configure.

In this case, the logger name is based on the "unique" database name which is initially autogenerated, but which you can change in HSQLDB.

fredt
  • 24,044
  • 3
  • 40
  • 61
0

Because as YWE noted hsqldb uses log4j by default if it is found in the classpath, I needed to figure out how to override the log4j.properties found in the 3rd-party library. This I managed to do as follows:

  1. Copy the existing log4j.properties to my project, and add the following line at the beginning:

    log4j.rootLogger=WARN, CONSOLE
    
  2. Add the following VM Arguments:

    -Dlog4j.log4j.defaultInitOverride=true
    -Dlog4j.configuration=C:/full/path/to/my/log4j.properties
    
  3. Make sure this line of code runs before anyone (e.g. hsqldb) attempts to use log4j:

    org.apache.log4j.PropertyConfigurator.configure("log4j.properties");
    
Isaac Sutherland
  • 3,082
  • 4
  • 28
  • 37