logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Sicker <boa...@gmail.com>
Subject Re: Is there anything besides the Logger name that uniquely identifies a Logger?
Date Thu, 15 Oct 2015 02:35:38 GMT
That's exactly what I was thinking. A simple writeReplace() and
readReplace() using the logger name and LogManager.getLogger(name).

On 14 October 2015 at 21:32, Ralph Goers <ralph.goers@dslextreme.com> wrote:

> I am not sure why you would need or want to serialize any plugins.  Logger
> basically references the LoggerContext and the PrivateConfig.  Both of
> these should be transient as it makes very little sense for those to be
> deserialized on a target implementation. But even serializing the actual
> Logger makes very little sense. On the target system you would want to call
> LogManager.getLogger(name) to recreate it.
>
> What I would suggest is to use the Proxy pattern that is used by
> Log4jLogEvent to serialize and deserialize the Logger. What would be
> different is that the serialization would basically only serialize the
> logger name and deserialization would call LogManager.getLogger(name).
>
> Ralph
>
> On Oct 14, 2015, at 7:02 PM, Matt Sicker <boards@gmail.com> wrote:
>
> Basically, to naively serialize a Logger, you need to serialize all the
> plugins associated with it. As most things in log4j-core can be classified
> as either plugins or "framework" code, that's really most of the codebase.
>
> On 14 October 2015 at 18:00, Gary Gregory <garydgregory@gmail.com> wrote:
>
>> If it's really 50%, then yeah, that's suspicious. I'd like to hear if
>> Ralph or Remko have any insights here.
>>
>> Gary
>>
>> On Wed, Oct 14, 2015 at 3:04 PM, Matt Sicker <boards@gmail.com> wrote:
>>
>>> Most people use a static field to store the Logger, so most use cases
>>> don't require serialization. For instance fields, it might work better to
>>> declare it transient, and in that case, our implementation of Logger should
>>> not be Serializable at all. Otherwise, there are ways to serialize
>>> everything, but the way it looks, that will require making over 50% of the
>>> code base Serializable which doesn't smell right to me.
>>>
>>> On 14 October 2015 at 16:54, Gary Gregory <garydgregory@gmail.com>
>>> wrote:
>>>
>>>> It would be a neat trick to only use the logger name for ser/deser. But
>>>> a logger only exists in a LC, so how would you re-create the Logger object.
>>>> LogManager.getLogger(String) can't account for the message factory for
>>>> example. Would knowing the class within which the static Logger resides be
>>>> enough to know which LC to use? I do not see how :-( I think we need
>>>> Ralph's insight here.
>>>>
>>>> The alternative would be... to recommend that all Logger declarations
>>>> be transient? That does not seen realistic, especially accounting for code
>>>> you cannot change.
>>>>
>>>> Gary
>>>>
>>>> On Wed, Oct 14, 2015 at 2:48 PM, Matt Sicker <boards@gmail.com> wrote:
>>>>
>>>>> Perhaps besides a particular LoggerContext. I have an idea on how to
>>>>> significantly simplify the serialization of Logger, and if we can simply
>>>>> unserialize it based purely on its name, then that would save a lot of
>>>>> trouble. I don't remember if we've discussed this idea in the past, but
I
>>>>> think this would be the best way to implement serialization in Logger.
I
>>>>> wouldn't want to pass a Logger over the wire and clobber a possibly
>>>>> different configuration already in memory at the time, for instance.
>>>>>
>>>>> --
>>>>> Matt Sicker <boards@gmail.com>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>> Java Persistence with Hibernate, Second Edition
>>>> <http://www.manning.com/bauer3/>
>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>> Blog: http://garygregory.wordpress.com
>>>> Home: http://garygregory.com/
>>>> Tweet! http://twitter.com/GaryGregory
>>>>
>>>
>>>
>>>
>>> --
>>> Matt Sicker <boards@gmail.com>
>>>
>>
>>
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> Java Persistence with Hibernate, Second Edition
>> <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>>
>
>
>
> --
> Matt Sicker <boards@gmail.com>
>
>
>


-- 
Matt Sicker <boards@gmail.com>

Mime
View raw message