Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting rid of derby.log

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.

like image 515
Allan Lykke Christensen Avatar asked Jun 16 '09 22:06

Allan Lykke Christensen


People also ask

Can I delete Derby log?

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.

How do you get rid of Derby?

Right-click the project to bring up the context menu and select the menu item, Apache Derby, Remove Apache Derby nature.

What is Derby log file?

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.


2 Answers

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> 
like image 147
Laurent Fournié Avatar answered Sep 20 '22 23:09

Laurent Fournié


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.

like image 26
stevedbrown Avatar answered Sep 20 '22 23:09

stevedbrown