7

I have an embedded Hsqldb set up in my project. But it dumps a lot of info on the output when working, and I currently do not need that info:

Mar 29, 2012 10:18:11 PM org.hsqldb.persist.Logger logInfoEvent
INFO: Checkpoint start
Mar 29, 2012 10:18:11 PM org.hsqldb.persist.Logger logInfoEvent
INFO: checkpointClose start
Mar 29, 2012 10:18:11 PM org.hsqldb.persist.Logger logInfoEvent
INFO: checkpointClose end
Mar 29, 2012 10:18:11 PM org.hsqldb.persist.Logger logInfoEvent
INFO: Checkpoint end

Is there a way to silence that output?

Rogach
  • 26,050
  • 21
  • 93
  • 172
  • possible duplicate of [hsqldb messing up with my server´s logs](http://stackoverflow.com/questions/5969321/hsqldb-messing-up-with-my-servers-logs) – fglez Apr 04 '13 at 07:33

4 Answers4

7

Unfortunately, i don't believe so. we have the same issue in our project. i believe i checked the source at one point in time and concluded that hsqldb does not provide a way to influence this logging.

I stand corrected (as @fredt mentioned in his comment to the other answer), you can control this logging via the jdk log levels. setting the "hsqldb.db" log level to something like WARNING will suppress this output. you can do this using the logging.properties file or programmatically (after hsqldb loads) using something like Logger.getLogger("hsqldb.db").setLevel(Level.WARNING) (assuming you are using java util logging).

As noted in the comment below, hsqldb also resets the java logging configuration. If embedding it in another application, you may want to disable that functionality by setting the system property "hsqldb.reconfig_logging" to "false" (before hsqldb is loaded).

jtahlborn
  • 52,909
  • 5
  • 76
  • 118
  • 2
    Tried your suggested tweak, but INFO messages continued to appear after a certain point in my application until I also added `System.setProperty("hsqldb.reconfig_logging", "false");` at the beginning of my code. (I found that system property in the HSQLDB documentation via the link in Fred's comment to the other answer.) – Gord Thompson Aug 14 '16 at 16:26
  • 1
    @GordThompson heh, yes, hsqldb also tries to claim ownership over the java logging configuration, so you need to disable that. updated my answer. – jtahlborn Aug 14 '16 at 18:21
1

For anyone looking for a command line solution.

Start your app/server with a property pointing to the location of a dedicated properties file:

-Djava.util.logging.config.file=/location/of/your/hsqldblog.properties"

Which contains the following line to change Java logging for Hsqldb.

# Change hsqldb logging level 
org.hsqldb.persist = WARNING

Side note, you can choose from the following levels:

SEVERE WARNING INFO CONFIG FINE FINER FINEST

More info on Java Logging

Tomasz
  • 5,269
  • 8
  • 56
  • 65
1

For Slf4j + Logback users:

Add log4j-over-slf4j as a dependency (don't forget to exclude original log4j dependency if you have any). If you use Gradle, add something like this into your build.gradle:

runtime group: 'org.slf4j', name: 'log4j-over-slf4j', version: '1.7.25'

Then, add this to your logback.xml:

<logger name="hsqldb.db" level="warn"/>
Kohei Nozaki
  • 1,154
  • 1
  • 13
  • 36
0

You can use setSilent(true) when starting server from code:

Server server = new Server();
server.setSilent(true);
server.setDatabaseName(0, "mainDb");
server.setDatabasePath(0, "mem:mainDb");
server.setPort(9001);
server.start();
ron190
  • 1,032
  • 1
  • 17
  • 29