'Java EmbeddedDatabase (H2) logging
I would like to change the logging of my EmbeddedDatabase. Atm every time I open a connection it logs "... Creating new JDBC Driver Connection to ...". In my test suite, I open for every request a new connection, and now there are way too many of these messages.
EmbeddedDatabase embeddedDatabase = new EmbeddedDatabaseBuilder()
.generateUniqueName(true)
.setType(EmbeddedDatabaseType.H2)
.build();
...
Connection connection = embeddedDatabase.getConnection();
I didn't find any kind of log level. I just can set the PrintWriter. But I wanna see the error msgs. I run this outside of spring as a regular unit test.
Any ideas?
Solution 1:[1]
It seem like the getConnection method from the EmbeddedDatabase and from the DriverManager create a different log strategie for the connection. The default config fits for my problem. So the code would look like this:
new EmbeddedDatabaseBuilder()
.setName("test")
.setType(EmbeddedDatabaseType.H2)
.build();
...
Connection connection = DriverManager
.getConnection("jdbc:h2:mem:test", "sa", "");
... or
Connection connection = DriverManager
.getConnection("jdbc:h2:mem:test;TRACE_LEVEL_SYSTEM_OUT=3", "sa", "");
More options: https://h2database.com/html/features.html#trace_options
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
