Making the SLF4J Logger serializable doesn't imply that the Log4j Logger needs 
to be Serializable.  Since the Loggers in both Logback and the SLF4J wrapper to 
Log4j 1.x are Serializable it seems obvious to me that the SLF4J to Log4j 2 
Logger should also be.

As for the Log4j 2 Logger it might make sense to also have that be Serializable 
as well just to limit restrictions on where it can be used. 

Ralph

On Sep 25, 2013, at 7:20 AM, Nick Williams wrote:

> Well I personally don't see a reason for loggers to be serialized. IMO, if 
> you put loggers in domain objects, "you're doing it wrong." But that's just 
> my stance.
> 
> IF you need to put a logger in a domain object, just make it static! There's 
> no advantage to it being an instance variable over it being static, but there 
> IS an advantage to it being static--serialization doesn't matter.
> 
> IF we make serializable loggers, then YES, they should be usable as a logger 
> in the new JVM, but only IF Log4j is configured in the other JVM.
> 
> N
> 
> On Sep 25, 2013, at 2:28 AM, Remko Popma wrote:
> 
>> Hm...
>> If you serialize an object & send it over the wire, then de-serialize it to 
>> another JVM, do you expect it to still be usable as a logger in the new JVM?
>> 
>> On Wednesday, September 25, 2013, lvlin zeng (JIRA) wrote:
>> 
>>     [ 
>> https://issues.apache.org/jira/browse/LOG4J2-410?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13777136#comment-13777136
>>  ]
>> 
>> lvlin zeng commented on LOG4J2-410:
>> -----------------------------------
>> 
>> so i think the Logger and some other related classes should be 
>> serializable,when i use log4j1.x,no exception happens,if some people migrate 
>> the log4j from 1.x to 2.x ,they need to change some codes^_^
>> 
>> >  java.io.NotSerializableException: org.slf4j.impl.SLF4JLogger
>> > -------------------------------------------------------------
>> >
>> >                 Key: LOG4J2-410
>> >                 URL: https://issues.apache.org/jira/browse/LOG4J2-410
>> >             Project: Log4j 2
>> >          Issue Type: Bug
>> >    Affects Versions: 2.0-beta8
>> >            Reporter: lvlin zeng
>> >
>> > When i use a the logger object in a model,and the model will set to some 
>> > cache like memcached,this exception happens.Maybe this class and some 
>> > other related class need implements Serializable interface?
>> 
>> --
>> This message is automatically generated by JIRA.
>> If you think it was sent incorrectly, please contact your JIRA administrators
>> For more information on JIRA, see: http://www.atlassian.com/software/jira
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org
>> For additional commands, e-mail: log4j-dev-h...@logging.apache.org
>> 
> 

Reply via email to