You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Andrew Willerding <aw...@callistacti.com> on 2015/05/11 15:51:17 UTC

Cayenne 4.0 and logging

I'm trying to change the logging level for my Cayenne 4.0 project but so 
far I haven't had any luck.  I'm also using log4j2 for the first time in 
my project.  In other projects I have simply followed these instructions 
to modify the log4j.properties file and everything worked as expected.

# Turn SQL tracing on
log4j.logger.org.apache.cayenne.access.QueryLogger = INFO

# Turn SQL tracing off, e.g. to increase performance
log4j.logger.org.apache.cayenne.access.QueryLogger = WARN

For my new project with the log4j2 libraries, I have created a 
log4j.properties file with the appropriate settings but the cayenne 
logging is still in INFO mode.  And I'm not sure where to place the 
log4j.properties file so it can be found by Cayenne.

On the log4j2 side, I have also tried to add a setting in the log4j2.xml 
file to disable the cayenne logging but still it still had no effect on 
the logging detail.  Here's the logger excerpt from my log4j2.xml files

            <logger name="org.apache.cayenne.access.QueryLogger" 
level="WARN">
                <AppenderRef ref="ADEFAULT"/>
            </logger>

I'm not sure what else to try at this point so some guidance would be 
appreciated.

Thanks,

Andrew


Re: Cayenne 4.0 and logging

Posted by Andrew Willerding <aw...@itsurcom.com>.
Thank you Alex.  Your reply got me going on the right track and I've 
been able to make the changes to log4j2 to take back control of the 
Cayenne logging once again.

I don't use Maven so for the record I added the two jar files you 
pointed out below to my project, added the Logger settings you also 
detailed below and "like magic"
, it all came together.




On 05/11/2015 10:43 AM, Alex Kolonitsky wrote:
> Cayenne uses apache commons logging as logging interface and if you want to use log4j2 implementation you must include dependency to log4j-core and log4j-jcl  <https://logging.apache.org/log4j/2.x/maven-artifacts.html#Apache_Commons_Logging_Bridge>bridge library:
>
> <dependency>
>      <groupId>org.apache.logging.log4j</groupId>
>      <artifactId>log4j-core</artifactId>
>      <version>2.2</version>
> </dependency>
> <dependency>
>      <groupId>org.apache.logging.log4j</groupId>
>      <artifactId>log4j-jcl</artifactId>
>      <version>2.2</version>
> </dependency>
>
> and create log4j2.xml in classpath. For instance lines below turn off logging for me:
>
> <Logger name="org.apache.cayenne" level="off">
>      <AppenderRef ref="Console"/>
> </Logger>
>
>
>
>> On May 11, 2015, at 5:24 PM, Aristedes Maniatis <ar...@maniatis.org> wrote:
>>
>> On 11/05/2015 11:51pm, Andrew Willerding wrote:
>>> For my new project with the log4j2 libraries, I have created a log4j.properties file with the appropriate settings but the cayenne logging is still in INFO mode.  And I'm not sure where to place the log4j.properties file so it can be found by Cayenne.
>> log4j version 2 uses an xml configuration file, not a properties file. Also, because Cayenne is hooked into the old log4j version 1 library, you'll need the compatibility library for log4jv2 that let's it accept the old API.
>>
>> Ari
>>
>>
>> -- 
>> -------------------------->
>> Aristedes Maniatis
>> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>>
>


Re: Cayenne 4.0 and logging

Posted by Alex Kolonitsky <ak...@objectstyle.com>.
Cayenne uses apache commons logging as logging interface and if you want to use log4j2 implementation you must include dependency to log4j-core and log4j-jcl  <https://logging.apache.org/log4j/2.x/maven-artifacts.html#Apache_Commons_Logging_Bridge>bridge library:

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.2</version>
</dependency>
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-jcl</artifactId>
    <version>2.2</version>
</dependency>

and create log4j2.xml in classpath. For instance lines below turn off logging for me:

<Logger name="org.apache.cayenne" level="off">
    <AppenderRef ref="Console"/>
</Logger>



> On May 11, 2015, at 5:24 PM, Aristedes Maniatis <ar...@maniatis.org> wrote:
> 
> On 11/05/2015 11:51pm, Andrew Willerding wrote:
>> For my new project with the log4j2 libraries, I have created a log4j.properties file with the appropriate settings but the cayenne logging is still in INFO mode.  And I'm not sure where to place the log4j.properties file so it can be found by Cayenne.
> 
> log4j version 2 uses an xml configuration file, not a properties file. Also, because Cayenne is hooked into the old log4j version 1 library, you'll need the compatibility library for log4jv2 that let's it accept the old API.
> 
> Ari
> 
> 
> -- 
> -------------------------->
> Aristedes Maniatis
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
> 


Re: Cayenne 4.0 and logging

Posted by Mike Kienenberger <mk...@gmail.com>.
You could also look at slf4j for your bridging software.

http://www.slf4j.org/legacy.html

with log4j-over-slf4.jar convering old log4j version 1 api calls into
slf4j calls.  From there you can log to whatever you like.   Same with
old JCL calls.


On Mon, May 11, 2015 at 10:24 AM, Aristedes Maniatis <ar...@maniatis.org> wrote:
> On 11/05/2015 11:51pm, Andrew Willerding wrote:
>> For my new project with the log4j2 libraries, I have created a log4j.properties file with the appropriate settings but the cayenne logging is still in INFO mode.  And I'm not sure where to place the log4j.properties file so it can be found by Cayenne.
>
> log4j version 2 uses an xml configuration file, not a properties file. Also, because Cayenne is hooked into the old log4j version 1 library, you'll need the compatibility library for log4jv2 that let's it accept the old API.
>
> Ari
>
>
> --
> -------------------------->
> Aristedes Maniatis
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A

Re: Cayenne 4.0 and logging

Posted by Aristedes Maniatis <ar...@maniatis.org>.
On 11/05/2015 11:51pm, Andrew Willerding wrote:
> For my new project with the log4j2 libraries, I have created a log4j.properties file with the appropriate settings but the cayenne logging is still in INFO mode.  And I'm not sure where to place the log4j.properties file so it can be found by Cayenne.

log4j version 2 uses an xml configuration file, not a properties file. Also, because Cayenne is hooked into the old log4j version 1 library, you'll need the compatibility library for log4jv2 that let's it accept the old API.

Ari


-- 
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A