db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John H. Embretsen" <John.Embret...@Sun.COM>
Subject Re: how to turn off all derby logging , specially derby.log
Date Sat, 14 Oct 2006 11:42:53 GMT
legolas wood wrote:

> Hi
> Thank you for reply.
> I should use them in embedded Derby , so i can not pass parameters to it
> or try to set OS parameter because it goes to run on clients machines.
> so i asked for  a method that allows me use them from my java codes.

If I understand you correctly, you have made a Java/JDBC application 
using the embedded driver that you plan to distribute to multiple 
machines, and you won't have control of the parameters used to start the 
application.

If you are using the embedded driver, you can still use a 
derby.properties file to set the properties (place it in the working 
directory of your Java program). Alternatively, you can set the 
properties in your Java code before you load the driver, for example:

System.setProperty(propertyKey, propertyValue);
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
...

(see JavaDoc for java.lang.System.setProperty() )

For example, if you want to disable all info/error logging completely, 
you can create a method implementing a stream as follows:

public static java.io.OutputStream disableDerbyLogFile(){
     return new java.io.OutputStream() {
         public void write(int b) throws IOException {
             // Ignore all log messages
         }
     };
}

Let's say this method is in a class called MyProgram. Then you would 
disable all logging by setting the property derby.stream.error.method 
and point it to that method, like this:

System.setProperty("derby.stream.error.method", 
"MyProgram.disableDerbyLogFile");



-- 
John


Mime
View raw message