You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Veaceslav Chicu <cs...@infologic.fr> on 2005/08/02 12:34:48 UTC

Re: jdbc trace

Hi Stanley,

I want all sql messages, parameteres, commit/rollback

I tried DriverManager.setLogWriter(new ...) with no succes

maybe derby.language.logStatementText=true should help me?

where is information log file?

thank you,
Slavic


Stanley Bradbury wrote:
> Hi Slavic -
> 
> I'm going to guess that by trace messages you mean the messages that
> normally are written to the derby.log file.  There are two methods that
> can be used redirect Derby messages.  These are:
> derby.stream.error.method  and
> derby.stream.error.field
> 
> They were omitted in the initial version 10 documentation - you can read
> about them in the 10.1 manuals posted on the Apache Incubator site for
> derby
> 
> I can get all derby.log messages sent to the terminal by setting ..field
> to java.lang.System.out
> I.E.
> java -Dderby.stream.error.field=java.lang.System.out
> org.apache.derby.tools.ij
> 
> Please post again and let me know if this is the information you needed
> or correct my assumption on the meaning of  'trace messages' and I will
> try again.
> 
> Veaceslav Chicu wrote:
> 
>> Hi,
>>
>> how can I write all trace messages to console?
>> System.out
>>
>> thank you,
>> Slavic
>>
>>  
>>
> 
> 
> 


Re: jdbc trace

Posted by Veaceslav Chicu <cs...@infologic.fr>.
Thank you,

that is :)

Slavic

Army wrote:
> Veaceslav Chicu wrote:
> 
>> it's ok
>> can I redirect this information to console?
> 
> 
> If the info you want is the info from setting
> "derby.language.logStatementText" to true, then you can redirect it to
> output using Stanley's suggestion (see his original response to your
> email).
> 
> Ex. If your program is called "myProg", then the following would run
> your program and redirect all of "logStatementText" info to System.out:
> 
> java -Dderby.language.logStatementText=true
> -Dderby.stream.error.field=java.lang.System.out myProg
> 
> If that does what you want, then you don't have to worry about
> "setLogWriter()" and can stop reading now :)
> 
>> I have:
>>
>> Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
>> Connection conn = DriverManager.getConnection("jdbc:derby:bookstoredb;",
>> "slavic", "cs");
>> DriverManager.setLogWriter(new PrintWriter(new
>> FileOutputStream("trace.txt")));
>> why trace.txt is empty? why I don't see log information there?
> 
> 
> 1) The documentation at the links you pasted says that
> DriverManager.setLogWriter() has to be called BEFORE the connection is
> made. The code snippet that you pasted connects first, and then calls
> setLogWriter(), so it won't work.
> 
> 2) For completeness, you should make sure you are flushing/closing the
> PrintWriter stream before terminating your program.
> 
> 3) If you really want the information that is written by
> "setLogWriter()" (instead of the information that is written when
> derby.language.logStatementText is true), and if you want to redirect
> that output to the console, then your code should look like this:
> 
>     PrintWriter pW = new PrintWriter(System.out);
>     DriverManager.setLogWriter(pW);
> 
>     Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
>     Connection conn =
>         DriverManager.getConnection("jdbc:derby:bookstoredb",
>         "slavic", "cs");
> 
> 
> Hope that helps,
> Army
> 
> 


Re: jdbc trace

Posted by Army <qo...@sbcglobal.net>.
Veaceslav Chicu wrote:
> it's ok
> can I redirect this information to console?

If the info you want is the info from setting "derby.language.logStatementText" 
to true, then you can redirect it to output using Stanley's suggestion (see his 
original response to your email).

Ex. If your program is called "myProg", then the following would run your 
program and redirect all of "logStatementText" info to System.out:

java -Dderby.language.logStatementText=true 
-Dderby.stream.error.field=java.lang.System.out myProg

If that does what you want, then you don't have to worry about "setLogWriter()" 
and can stop reading now :)

> I have:
> 
> Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
> Connection conn = DriverManager.getConnection("jdbc:derby:bookstoredb;",
> "slavic", "cs");
> DriverManager.setLogWriter(new PrintWriter(new
> FileOutputStream("trace.txt")));
> why trace.txt is empty? why I don't see log information there?

1) The documentation at the links you pasted says that 
DriverManager.setLogWriter() has to be called BEFORE the connection is made. 
The code snippet that you pasted connects first, and then calls setLogWriter(), 
so it won't work.

2) For completeness, you should make sure you are flushing/closing the 
PrintWriter stream before terminating your program.

3) If you really want the information that is written by "setLogWriter()" 
(instead of the information that is written when derby.language.logStatementText 
is true), and if you want to redirect that output to the console, then your code 
should look like this:

	PrintWriter pW = new PrintWriter(System.out);
	DriverManager.setLogWriter(pW);

	Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
	Connection conn =
		DriverManager.getConnection("jdbc:derby:bookstoredb",
		"slavic", "cs");


Hope that helps,
Army


Re: jdbc trace

Posted by Veaceslav Chicu <cs...@infologic.fr>.
it's ok
can I redirect this information to console?

I have:

Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
Connection conn = DriverManager.getConnection("jdbc:derby:bookstoredb;",
"slavic", "cs");
DriverManager.setLogWriter(new PrintWriter(new
FileOutputStream("trace.txt")));

why trace.txt is empty? why I don't see log information there?

http://publib.boulder.ibm.com/infocenter/db2help/index.jsp?topic=/com.ibm.db2.udb.pd.doc/pd/t0020709.htm
http://publib.boulder.ibm.com/infocenter/db2help/index.jsp?topic=/com.ibm.db2.udb.doc/ad/cjvjctrc.htm

thank you,
Slavic




Francois Orsini wrote:
> Yes, derby.language.logStatementText database property is very likely
> what you want...will dump text and parameter values of all executed
> statements as well as write commits and rollbacks tracing info (if I
> remember correctly)...
> 
> Derby log file (derby.log) info be found here:
> http://incubator.apache.org/derby/docs/devguide/cdevdvlp25889.html
> 
> --francois
> 
> On 8/2/05, Veaceslav Chicu <cs...@infologic.fr> wrote:
> 
>>Hi Stanley,
>>
>>I want all sql messages, parameteres, commit/rollback
>>
>>I tried DriverManager.setLogWriter(new ...) with no succes
>>
>>maybe derby.language.logStatementText=true should help me?
>>
>>where is information log file?
>>
>>thank you,
>>Slavic
>>
>>
>>Stanley Bradbury wrote:
>>
>>>Hi Slavic -
>>>
>>>I'm going to guess that by trace messages you mean the messages that
>>>normally are written to the derby.log file.  There are two methods that
>>>can be used redirect Derby messages.  These are:
>>>derby.stream.error.method  and
>>>derby.stream.error.field
>>>
>>>They were omitted in the initial version 10 documentation - you can read
>>>about them in the 10.1 manuals posted on the Apache Incubator site for
>>>derby
>>>
>>>I can get all derby.log messages sent to the terminal by setting ..field
>>>to java.lang.System.out
>>>I.E.
>>>java -Dderby.stream.error.field=java.lang.System.out
>>>org.apache.derby.tools.ij
>>>
>>>Please post again and let me know if this is the information you needed
>>>or correct my assumption on the meaning of  'trace messages' and I will
>>>try again.
>>>
>>>Veaceslav Chicu wrote:
>>>
>>>
>>>>Hi,
>>>>
>>>>how can I write all trace messages to console?
>>>>System.out
>>>>
>>>>thank you,
>>>>Slavic
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
> 


Re: jdbc trace

Posted by Francois Orsini <fr...@gmail.com>.
Yes, derby.language.logStatementText database property is very likely
what you want...will dump text and parameter values of all executed
statements as well as write commits and rollbacks tracing info (if I
remember correctly)...

Derby log file (derby.log) info be found here:
http://incubator.apache.org/derby/docs/devguide/cdevdvlp25889.html

--francois

On 8/2/05, Veaceslav Chicu <cs...@infologic.fr> wrote:
> Hi Stanley,
> 
> I want all sql messages, parameteres, commit/rollback
> 
> I tried DriverManager.setLogWriter(new ...) with no succes
> 
> maybe derby.language.logStatementText=true should help me?
> 
> where is information log file?
> 
> thank you,
> Slavic
> 
> 
> Stanley Bradbury wrote:
> > Hi Slavic -
> >
> > I'm going to guess that by trace messages you mean the messages that
> > normally are written to the derby.log file.  There are two methods that
> > can be used redirect Derby messages.  These are:
> > derby.stream.error.method  and
> > derby.stream.error.field
> >
> > They were omitted in the initial version 10 documentation - you can read
> > about them in the 10.1 manuals posted on the Apache Incubator site for
> > derby
> >
> > I can get all derby.log messages sent to the terminal by setting ..field
> > to java.lang.System.out
> > I.E.
> > java -Dderby.stream.error.field=java.lang.System.out
> > org.apache.derby.tools.ij
> >
> > Please post again and let me know if this is the information you needed
> > or correct my assumption on the meaning of  'trace messages' and I will
> > try again.
> >
> > Veaceslav Chicu wrote:
> >
> >> Hi,
> >>
> >> how can I write all trace messages to console?
> >> System.out
> >>
> >> thank you,
> >> Slavic
> >>
> >>
> >>
> >
> >
> >
> 
>