I'm using the Apache Derby embedded database for unit testing in a Maven project. Unfortunately whenever I run the test I end up with the derby.log
file in the root of the project. The database itself is created in the target
directory (jdbc:derby:target/unittest-db;create=true
) so that is not a problem. After consulting the reference guide I tried setting the logDevice
parameter on the JDBC url (jdbc:derby:target/unittest-db;create=true;logDevice=/mylogs
) but that seems to be for a different log, hence derby.log
still appears.
Any help is much appreciated.
Content. The bottom line: Never delete or manipulate *ANY* files in a Derby database directory structure. Doing so will corrupt the database. The problem: Some Derby users have discovered that deleting the files in the log subdirectory of the database will silence recovery errors and allow access the database.
Right-click the project to bring up the context menu and select the menu item, Apache Derby, Remove Apache Derby nature.
The derby. log file is created when the Derby server is booted. The network server records the time and version. If a log file exists, it is overwritten, unless the property derby.
Derby lets you specify the name of the file to which the error log messages are written using the Java system property derby.stream.error.file
. The default value is 'derby.log'.
To get rid of derby.log
during the Maven surefire testing phase, I just add the property definition in the plugin configuration as follows:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <systemProperties> <property> <name>derby.stream.error.file</name> <value>target/derby.log</value> </property> </systemProperties> </configuration> </plugin>
You can get rid of derby.log
file by creating the following class
public class DerbyUtil { public static final OutputStream DEV_NULL = new OutputStream() { public void write(int b) {} }; }
and setting the JVM system property derby.stream.error.field
, for example, using the following JVM command-line argument:
-Dderby.stream.error.field=DerbyUtil.DEV_NULL
Credit to whom it is due.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With