You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by Andrus Adamchik <an...@objectstyle.org> on 2017/03/27 18:47:47 UTC

Switching Cayenne to SLF4J

We discussed this as far back as 2013:

https://lists.apache.org/thread.html/5ccad102f7d9dc575bb5bd352462443bc9d8c2763aa15fbf4a0f757f@1366718807@%3Cdev.cayenne.apache.org%3E

Now may be a good time to bring it up again. I suggest that in 4.0 we replace our commons-logging dependency with slf4j-api dependency. This should not make anything worse, but will make things slightly better from the integration perspective. SLF4J is probably the most commonly used "least common denominator" logging API these days, so Cayenne will be easier to setup in the majority of cases.

So unless there are specific objections, we'll implement this change.

Andrus

Re: Switching Cayenne to SLF4J

Posted by Nikita Timofeev <nt...@objectstyle.com>.
Hi all,

There is PR with SLF4J ready to be applied.
Switching to parameters logging like this:

logger.debug("Some data: {}", anObject)

is not there yet, only wiping out of commons-logging is done.

And after switching to SLF4J users will need to include at least
slf4j-simple to have some logging output.
This change doesn't seem important to me, as it will only affect small
apps with no logging yet, this also
will be mentioned in Cayenne getting started guide and upgrade notes.

On Wed, Mar 29, 2017 at 1:03 PM, Aristedes Maniatis <ar...@maniatis.org> wrote:
> I notice it also supports lazy evaluation of the logging data. That is, you can write:
>
> logger.debug("Some data: {}", anObject)
>
> Without worrying about the time to convert anObject to a string. That will remove a lot of code like:
>
> if (logger.isDebugEnabled()) {
>
> }
>
> That alone seems worth it.
>
> Ari
>
>
> On 29/3/17 4:52pm, Andrus Adamchik wrote:
>> Also AFAIK commons-logging does not support MDC [1]. The use of MDC may improve Cayenne transaction tracking in the logs.
>>
>> Andrus
>>
>> [1] https://logback.qos.ch/manual/mdc.html
>>
>>> On Mar 28, 2017, at 1:53 AM, Mike Kienenberger <mk...@gmail.com> wrote:
>>>
>>> On Mon, Mar 27, 2017 at 6:20 PM, Aristedes Maniatis <ar...@maniatis.org> wrote:
>>>> * using log4j or other library
>>>
>>> Pick one logging library (ie, log4j).  Add the "log to log4j from slf4j" jar.
>>> For all other logging libraries, add "log to slf4j from *" jars.
>>>
>>> It's pretty much that simple, although really badly designed logging
>>> libraries like java.util.logging may require extra steps or run
>>> poorly.
>>>
>>>
>>>> * having other libraries in the classpath with different versions of slf4j
>>>
>>> the slf4j api is pretty much backward compatible no matter what
>>> version you use, and jars don't inline slf4j.   So you can just pick
>>> whatever version you like, generally the latest slf4j version
>>> available.
>>
>
> --
> -------------------------->
> Aristedes Maniatis
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A



-- 
Best regards,
Nikita Timofeev

Re: Switching Cayenne to SLF4J

Posted by Aristedes Maniatis <ar...@maniatis.org>.
I notice it also supports lazy evaluation of the logging data. That is, you can write:

logger.debug("Some data: {}", anObject)

Without worrying about the time to convert anObject to a string. That will remove a lot of code like:

if (logger.isDebugEnabled()) {

}

That alone seems worth it.

Ari


On 29/3/17 4:52pm, Andrus Adamchik wrote:
> Also AFAIK commons-logging does not support MDC [1]. The use of MDC may improve Cayenne transaction tracking in the logs.
> 
> Andrus
> 
> [1] https://logback.qos.ch/manual/mdc.html
> 
>> On Mar 28, 2017, at 1:53 AM, Mike Kienenberger <mk...@gmail.com> wrote:
>>
>> On Mon, Mar 27, 2017 at 6:20 PM, Aristedes Maniatis <ar...@maniatis.org> wrote:
>>> * using log4j or other library
>>
>> Pick one logging library (ie, log4j).  Add the "log to log4j from slf4j" jar.
>> For all other logging libraries, add "log to slf4j from *" jars.
>>
>> It's pretty much that simple, although really badly designed logging
>> libraries like java.util.logging may require extra steps or run
>> poorly.
>>
>>
>>> * having other libraries in the classpath with different versions of slf4j
>>
>> the slf4j api is pretty much backward compatible no matter what
>> version you use, and jars don't inline slf4j.   So you can just pick
>> whatever version you like, generally the latest slf4j version
>> available.
> 

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

Re: Switching Cayenne to SLF4J

Posted by Andrus Adamchik <an...@objectstyle.org>.
Also AFAIK commons-logging does not support MDC [1]. The use of MDC may improve Cayenne transaction tracking in the logs.

Andrus

[1] https://logback.qos.ch/manual/mdc.html

> On Mar 28, 2017, at 1:53 AM, Mike Kienenberger <mk...@gmail.com> wrote:
> 
> On Mon, Mar 27, 2017 at 6:20 PM, Aristedes Maniatis <ar...@maniatis.org> wrote:
>> * using log4j or other library
> 
> Pick one logging library (ie, log4j).  Add the "log to log4j from slf4j" jar.
> For all other logging libraries, add "log to slf4j from *" jars.
> 
> It's pretty much that simple, although really badly designed logging
> libraries like java.util.logging may require extra steps or run
> poorly.
> 
> 
>> * having other libraries in the classpath with different versions of slf4j
> 
> the slf4j api is pretty much backward compatible no matter what
> version you use, and jars don't inline slf4j.   So you can just pick
> whatever version you like, generally the latest slf4j version
> available.


Re: Switching Cayenne to SLF4J

Posted by Mike Kienenberger <mk...@gmail.com>.
On Mon, Mar 27, 2017 at 6:20 PM, Aristedes Maniatis <ar...@maniatis.org> wrote:
> * using log4j or other library

Pick one logging library (ie, log4j).  Add the "log to log4j from slf4j" jar.
For all other logging libraries, add "log to slf4j from *" jars.

It's pretty much that simple, although really badly designed logging
libraries like java.util.logging may require extra steps or run
poorly.


> * having other libraries in the classpath with different versions of slf4j

the slf4j api is pretty much backward compatible no matter what
version you use, and jars don't inline slf4j.   So you can just pick
whatever version you like, generally the latest slf4j version
available.

Re: Switching Cayenne to SLF4J

Posted by Aristedes Maniatis <ar...@maniatis.org>.
Having only ever used log4j since forever, can you point us to some articles or explain how a user would handle:

* using log4j or other library
* having other libraries in the classpath with different versions of slf4j

Ari



On 28/3/17 5:47am, Andrus Adamchik wrote:
> We discussed this as far back as 2013:
> 
> https://lists.apache.org/thread.html/5ccad102f7d9dc575bb5bd352462443bc9d8c2763aa15fbf4a0f757f@1366718807@%3Cdev.cayenne.apache.org%3E
> 
> Now may be a good time to bring it up again. I suggest that in 4.0 we replace our commons-logging dependency with slf4j-api dependency. This should not make anything worse, but will make things slightly better from the integration perspective. SLF4J is probably the most commonly used "least common denominator" logging API these days, so Cayenne will be easier to setup in the majority of cases.
> 
> So unless there are specific objections, we'll implement this change.
> 
> Andrus
> 

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