Rogach
Rogach

Reputation: 27200

Is there a way to silence hsqldb logging?

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?

Upvotes: 7

Views: 6046

Answers (5)

user1818726
user1818726

Reputation: 131

setSilent(true) still does not eliminate ALL of the logging at startup. In a test environment try this.

server.setLogWriter(new PrintWriter(new OutputStream() {
        
        @Override
        public void write(int b) throws IOException {
    
            
        }
    }));

Upvotes: 0

ron190
ron190

Reputation: 1102

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();

Upvotes: 0

Kohei Nozaki
Kohei Nozaki

Reputation: 1154

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"/>

Upvotes: 1

jtahlborn
jtahlborn

Reputation: 53694

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).

Upvotes: 7

Tomasz
Tomasz

Reputation: 5509

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

Upvotes: 1

Related Questions