You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Wernke zur Borg <w....@rheagroup.com> on 2012/01/24 09:35:15 UTC

CommonsJdbcEventLogger does not print the queries

Hi folks,

I switched from QueryLogger to CommonsJdbcEventLogger but now I can't 
get it to print the detailed queries any more.

I am trying to debug a problem with my code and I set:

log4j.logger.org.apache.cayenne.log.CommonsJdbcEventLogger = DEBUG

But all I get are these INFO messages:

cayenne INFO  [SwingWorker-pool-1-thread-1 01-24 09:27:17] 
CommonsJdbcEventLogger: --- transaction started.
cayenne INFO  [SwingWorker-pool-1-thread-1 01-24 09:27:17] 
CommonsJdbcEventLogger: === returned 0 rows. - took 32 ms.
cayenne INFO  [SwingWorker-pool-1-thread-1 01-24 09:27:17] 
CommonsJdbcEventLogger: +++ transaction committed.
cayenne INFO  [SwingWorker-pool-1-thread-1 01-24 09:27:17] 
CommonsJdbcEventLogger: --- transaction started.
cayenne INFO  [SwingWorker-pool-1-thread-1 01-24 09:27:17] 
CommonsJdbcEventLogger: *** error.

I had to put a breakpoint at the appropriate place to see the query, so 
I did find the cause of my problem. But does CommonsJdbcEventLogger no 
longer print the queries? I know for sure that QueryLogger did it when 
set to DEBUG or INFO level.

Thanks, Wernke



This email (including any attachments) may contain confidential and/or privileged
information or information otherwise protected from disclosure.  If you are not the
intended recipient, please notify the sender immediately, do not copy this message
or any attachments and do not use it or any purpose or disclose its content to any
person, but delete this message and any attachments from your system.
RHEA System S.A. (RHEA) disclaims any and all liability if this email transmission
was virus corrupted, altered or falsified.

If a Non Disclosure Agreement (NDA) exists between RHEA and the receiving
organization, then all contents shall be considered proprietary and covered under
the NDA.



Re: CommonsJdbcEventLogger does not print the queries

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Jan 24, 2012, at 2:26 PM, Christian Grobmeier wrote:

> I have not done this before, but in most cases of DI you need to have
> appropriate setters/getters to make the injection work. Doi you have
> them? (f.e. getLogger, setLogger (JdbcEventLogger logger) )


Actually no - Cayenne is injecting into ivars directly.

Andrus

Re: CommonsJdbcEventLogger does not print the queries

Posted by Wernke zur Borg <w....@rheagroup.com>.
On 2012-01-24 12:26, Christian Grobmeier wrote:
> Hello Wernke (sorry for misspelling your name in my first response),
>
> On Tue, Jan 24, 2012 at 12:23 PM, Wernke zur Borg
> <w....@rheagroup.com>  wrote:
>> Class JdbcAdapter has this:
>>
>> @Inject
>>      protected JdbcEventLogger logger;
> I have not done this before, but in most cases of DI you need to have
> appropriate setters/getters to make the injection work. Doi you have
> them? (f.e. getLogger, setLogger (JdbcEventLogger logger) )
>

Note that it does work with the original JdbcAdapter even though it does 
not have a setter for the logger.

Only when I inject my own subclass the logger injection does not take place.

>> My JdbcAdapter subclass apparently does not get a logger injected -
>> getLogger() returns null.
>>
>> Since I am not yet familiar with DI, I do not know how to get the logger
>> injected.
>>
>> I do have this, although it might not be needed (it does not make any
>> difference):
>>
>> Module m = new Module() {
>>     public void configure(Binder binder) {
>>        binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class);
>>        ...
>>
>> Thanks, Wernke
>>
>>
>>
>> This email (including any attachments) may contain confidential and/or privileged
>> information or information otherwise protected from disclosure.  If you are not the
>> intended recipient, please notify the sender immediately, do not copy this message
>> or any attachments and do not use it or any purpose or disclose its content to any
>> person, but delete this message and any attachments from your system.
>> RHEA System S.A. (RHEA) disclaims any and all liability if this email transmission
>> was virus corrupted, altered or falsified.
>>
>> If a Non Disclosure Agreement (NDA) exists between RHEA and the receiving
>> organization, then all contents shall be considered proprietary and covered under
>> the NDA.
>>
>>
>
>


-- 
/Wernke zur Borg
*Rhea System S.A.*
Robert-Bosch-Str. 7
64293 Darmstadt / Germany
Tel. +49-6151-8709591/


This email (including any attachments) may contain confidential and/or privileged
information or information otherwise protected from disclosure.  If you are not the
intended recipient, please notify the sender immediately, do not copy this message
or any attachments and do not use it or any purpose or disclose its content to any
person, but delete this message and any attachments from your system.
RHEA System S.A. (RHEA) disclaims any and all liability if this email transmission
was virus corrupted, altered or falsified.

If a Non Disclosure Agreement (NDA) exists between RHEA and the receiving
organization, then all contents shall be considered proprietary and covered under
the NDA.


Re: CommonsJdbcEventLogger does not print the queries

Posted by Christian Grobmeier <gr...@gmail.com>.
Hello Wernke (sorry for misspelling your name in my first response),

On Tue, Jan 24, 2012 at 12:23 PM, Wernke zur Borg
<w....@rheagroup.com> wrote:
> Class JdbcAdapter has this:
>
> @Inject
>     protected JdbcEventLogger logger;

I have not done this before, but in most cases of DI you need to have
appropriate setters/getters to make the injection work. Doi you have
them? (f.e. getLogger, setLogger (JdbcEventLogger logger) )


>
> My JdbcAdapter subclass apparently does not get a logger injected -
> getLogger() returns null.
>
> Since I am not yet familiar with DI, I do not know how to get the logger
> injected.
>
> I do have this, although it might not be needed (it does not make any
> difference):
>
> Module m = new Module() {
>    public void configure(Binder binder) {
>       binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class);
>       ...
>
> Thanks, Wernke
>
>
>
> This email (including any attachments) may contain confidential and/or privileged
> information or information otherwise protected from disclosure.  If you are not the
> intended recipient, please notify the sender immediately, do not copy this message
> or any attachments and do not use it or any purpose or disclose its content to any
> person, but delete this message and any attachments from your system.
> RHEA System S.A. (RHEA) disclaims any and all liability if this email transmission
> was virus corrupted, altered or falsified.
>
> If a Non Disclosure Agreement (NDA) exists between RHEA and the receiving
> organization, then all contents shall be considered proprietary and covered under
> the NDA.
>
>



-- 
http://www.grobmeier.de
https://www.timeandbill.de

Re: CommonsJdbcEventLogger does not print the queries

Posted by Wernke zur Borg <w....@rheagroup.com>.
Done.

https://issues.apache.org/jira/browse/CAY-1655

Thank you for your support!

Wernke


On 2012-01-24 14:10, Andrus Adamchik wrote:
> Hi Wernke
>
> Greatly appreciate if you could open a Jira. We will investigate the injection issue. Could be a bug.
>
> https://issues.apache.org/jira/browse/CAY
>
> Thanks!
> Andrus
>
> On Jan 24, 2012, at 2:23 PM, Wernke zur Borg wrote:
>
>> On 2012-01-24 11:28, Durchholz, Joachim wrote:
>>>> Now the question remains, how do you properly inject the logger into your own JdbcAdapter subclass?
>>> No coding required, it's part of the logging configuration.
>>> You configure a logger for the class, or for the package that your adapter subclass lives in, or for any superpackage of that.
>>>
>>> HTH
>>> Jo
>> Thanks, Jo, but this does not seem to be the problem.
>>
>> Class JdbcAdapter has this:
>>
>> @Inject
>>      protected JdbcEventLogger logger;
>>
>> My JdbcAdapter subclass apparently does not get a logger injected -
>> getLogger() returns null.
>>
>> Since I am not yet familiar with DI, I do not know how to get the logger
>> injected.
>>
>> I do have this, although it might not be needed (it does not make any
>> difference):
>>
>> Module m = new Module() {
>>     public void configure(Binder binder) {
>>        binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class);
>>        ...
>>
>> Thanks, Wernke
>>
>>
>>
>> This email (including any attachments) may contain confidential and/or privileged
>> information or information otherwise protected from disclosure.  If you are not the
>> intended recipient, please notify the sender immediately, do not copy this message
>> or any attachments and do not use it or any purpose or disclose its content to any
>> person, but delete this message and any attachments from your system.
>> RHEA System S.A. (RHEA) disclaims any and all liability if this email transmission
>> was virus corrupted, altered or falsified.
>>
>> If a Non Disclosure Agreement (NDA) exists between RHEA and the receiving
>> organization, then all contents shall be considered proprietary and covered under
>> the NDA.
>>
>>
>>


-- 
/Wernke zur Borg
*Rhea System S.A.*
Robert-Bosch-Str. 7
64293 Darmstadt / Germany
Tel. +49-6151-8709591/


This email (including any attachments) may contain confidential and/or privileged
information or information otherwise protected from disclosure.  If you are not the
intended recipient, please notify the sender immediately, do not copy this message
or any attachments and do not use it or any purpose or disclose its content to any
person, but delete this message and any attachments from your system.
RHEA System S.A. (RHEA) disclaims any and all liability if this email transmission
was virus corrupted, altered or falsified.

If a Non Disclosure Agreement (NDA) exists between RHEA and the receiving
organization, then all contents shall be considered proprietary and covered under
the NDA.


Re: CommonsJdbcEventLogger does not print the queries

Posted by Andrus Adamchik <an...@objectstyle.org>.
Hi Wernke

Greatly appreciate if you could open a Jira. We will investigate the injection issue. Could be a bug.

https://issues.apache.org/jira/browse/CAY

Thanks!
Andrus

On Jan 24, 2012, at 2:23 PM, Wernke zur Borg wrote:

> On 2012-01-24 11:28, Durchholz, Joachim wrote:
>>> Now the question remains, how do you properly inject the logger into your own JdbcAdapter subclass?
>> No coding required, it's part of the logging configuration.
>> You configure a logger for the class, or for the package that your adapter subclass lives in, or for any superpackage of that.
>> 
>> HTH
>> Jo
> 
> Thanks, Jo, but this does not seem to be the problem.
> 
> Class JdbcAdapter has this:
> 
> @Inject
>     protected JdbcEventLogger logger;
> 
> My JdbcAdapter subclass apparently does not get a logger injected - 
> getLogger() returns null.
> 
> Since I am not yet familiar with DI, I do not know how to get the logger 
> injected.
> 
> I do have this, although it might not be needed (it does not make any 
> difference):
> 
> Module m = new Module() {
>    public void configure(Binder binder) {
>       binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class);
>       ...
> 
> Thanks, Wernke
> 
> 
> 
> This email (including any attachments) may contain confidential and/or privileged
> information or information otherwise protected from disclosure.  If you are not the
> intended recipient, please notify the sender immediately, do not copy this message
> or any attachments and do not use it or any purpose or disclose its content to any
> person, but delete this message and any attachments from your system.
> RHEA System S.A. (RHEA) disclaims any and all liability if this email transmission
> was virus corrupted, altered or falsified.
> 
> If a Non Disclosure Agreement (NDA) exists between RHEA and the receiving
> organization, then all contents shall be considered proprietary and covered under
> the NDA.
> 
> 
> 


Re: CommonsJdbcEventLogger does not print the queries

Posted by Wernke zur Borg <w....@rheagroup.com>.
On 2012-01-24 11:28, Durchholz, Joachim wrote:
>> Now the question remains, how do you properly inject the logger into your own JdbcAdapter subclass?
> No coding required, it's part of the logging configuration.
> You configure a logger for the class, or for the package that your adapter subclass lives in, or for any superpackage of that.
>
> HTH
> Jo

Thanks, Jo, but this does not seem to be the problem.

Class JdbcAdapter has this:

@Inject
     protected JdbcEventLogger logger;

My JdbcAdapter subclass apparently does not get a logger injected - 
getLogger() returns null.

Since I am not yet familiar with DI, I do not know how to get the logger 
injected.

I do have this, although it might not be needed (it does not make any 
difference):

Module m = new Module() {
    public void configure(Binder binder) {
       binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class);
       ...

Thanks, Wernke



This email (including any attachments) may contain confidential and/or privileged
information or information otherwise protected from disclosure.  If you are not the
intended recipient, please notify the sender immediately, do not copy this message
or any attachments and do not use it or any purpose or disclose its content to any
person, but delete this message and any attachments from your system.
RHEA System S.A. (RHEA) disclaims any and all liability if this email transmission
was virus corrupted, altered or falsified.

If a Non Disclosure Agreement (NDA) exists between RHEA and the receiving
organization, then all contents shall be considered proprietary and covered under
the NDA.



RE: CommonsJdbcEventLogger does not print the queries

Posted by "Durchholz, Joachim" <Jo...@hennig-fahrzeugteile.de>.
> Now the question remains, how do you properly inject the logger into your own JdbcAdapter subclass?

No coding required, it's part of the logging configuration.
You configure a logger for the class, or for the package that your adapter subclass lives in, or for any superpackage of that.

HTH
Jo

Re: CommonsJdbcEventLogger does not print the queries

Posted by Wernke zur Borg <w....@rheagroup.com>.
On 2012-01-24 10:29, Christian Grobmeier wrote:
> Hello Werner,
>
> On Tue, Jan 24, 2012 at 9:35 AM, Wernke zur Borg
> <w....@rheagroup.com>  wrote:
>> I switched from QueryLogger to CommonsJdbcEventLogger but now I can't
>> get it to print the detailed queries any more.
>>
>> I am trying to debug a problem with my code and I set:
>>
>> log4j.logger.org.apache.cayenne.log.CommonsJdbcEventLogger = DEBUG
> not sure why this doesn't work anymore. But for a workaround you can
> level the whole cayenne package:
>
> log4j.logger.org.apache.cayenne=INFO
>
> This helped me to see the sql statements again.
>
> Cheers
> Christian

Hi Christian,

thanks for the hint, but in the meantime I found the reason for the 
problem, which is my custom JdbcAdapter subclass. I had to provide an 
own JdbcAdapter implementation for some other reason, and as a 
consequence of that I ran into a NullPointerException with 
SelectAction.performAction() where it says:

adapter.getJdbcEventLogger().logSelectCount( ... );

returning null for the logger. Since the logger is dynamically injected, 
it seems that this injection somehow does not work with my subclass. My 
workaround to create a logger in my subclass's constructor is working 
but apparently does not see the log level setting, which explains the 
effect that queries are not logged.

Now the question remains, how do you properly inject the logger into 
your own JdbcAdapter subclass?

Thanks, Wernke






This email (including any attachments) may contain confidential and/or privileged
information or information otherwise protected from disclosure.  If you are not the
intended recipient, please notify the sender immediately, do not copy this message
or any attachments and do not use it or any purpose or disclose its content to any
person, but delete this message and any attachments from your system.
RHEA System S.A. (RHEA) disclaims any and all liability if this email transmission
was virus corrupted, altered or falsified.

If a Non Disclosure Agreement (NDA) exists between RHEA and the receiving
organization, then all contents shall be considered proprietary and covered under
the NDA.



Re: CommonsJdbcEventLogger does not print the queries

Posted by Christian Grobmeier <gr...@gmail.com>.
Hello Werner,

On Tue, Jan 24, 2012 at 9:35 AM, Wernke zur Borg
<w....@rheagroup.com> wrote:
> I switched from QueryLogger to CommonsJdbcEventLogger but now I can't
> get it to print the detailed queries any more.
>
> I am trying to debug a problem with my code and I set:
>
> log4j.logger.org.apache.cayenne.log.CommonsJdbcEventLogger = DEBUG

not sure why this doesn't work anymore. But for a workaround you can
level the whole cayenne package:

log4j.logger.org.apache.cayenne=INFO

This helped me to see the sql statements again.

Cheers
Christian

>
> But all I get are these INFO messages:
>
> cayenne INFO  [SwingWorker-pool-1-thread-1 01-24 09:27:17]
> CommonsJdbcEventLogger: --- transaction started.
> cayenne INFO  [SwingWorker-pool-1-thread-1 01-24 09:27:17]
> CommonsJdbcEventLogger: === returned 0 rows. - took 32 ms.
> cayenne INFO  [SwingWorker-pool-1-thread-1 01-24 09:27:17]
> CommonsJdbcEventLogger: +++ transaction committed.
> cayenne INFO  [SwingWorker-pool-1-thread-1 01-24 09:27:17]
> CommonsJdbcEventLogger: --- transaction started.
> cayenne INFO  [SwingWorker-pool-1-thread-1 01-24 09:27:17]
> CommonsJdbcEventLogger: *** error.
>
> I had to put a breakpoint at the appropriate place to see the query, so
> I did find the cause of my problem. But does CommonsJdbcEventLogger no
> longer print the queries? I know for sure that QueryLogger did it when
> set to DEBUG or INFO level.
>
> Thanks, Wernke
>
>
>
> This email (including any attachments) may contain confidential and/or privileged
> information or information otherwise protected from disclosure.  If you are not the
> intended recipient, please notify the sender immediately, do not copy this message
> or any attachments and do not use it or any purpose or disclose its content to any
> person, but delete this message and any attachments from your system.
> RHEA System S.A. (RHEA) disclaims any and all liability if this email transmission
> was virus corrupted, altered or falsified.
>
> If a Non Disclosure Agreement (NDA) exists between RHEA and the receiving
> organization, then all contents shall be considered proprietary and covered under
> the NDA.
>
>



-- 
http://www.grobmeier.de
https://www.timeandbill.de