摆脱derby.log [英] Getting rid of derby.log
问题描述
我正在使用Apache Derby嵌入式数据库在Maven项目中进行单元测试。不幸的是,每当我运行测试时,我最终都会在项目的根目录中使用 derby.log
文件。数据库本身是在目标
目录中创建的( jdbc:derby:target / unittest-db; create = true
)所以这不是问题。在咨询参考指南后,我尝试设置<$ JDBC网址上的c $ c> logDevice 参数( jdbc:derby:target / unittest-db; create = true; logDevice = / mylogs
)但这似乎是针对不同的日志,因此 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.
任何帮助都非常感谢。
推荐答案
你可以摆脱 derby.log
文件创建以下类
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) {}
};
}
并设置JVM系统属性 derby.stream.error.field
,例如,使用以下JVM命令行参数:
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
这篇关于摆脱derby.log的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!