logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Remko Popma (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4J2-100) Allow Log4jLogEvent serialization with subclasses
Date Sat, 11 Jan 2014 06:39:51 GMT

    [ https://issues.apache.org/jira/browse/LOG4J2-100?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13868682#comment-13868682

Remko Popma commented on LOG4J2-100:

A year has passed since this discussion.
Would it be okay to close this issue as "Won't fix"?

> Allow Log4jLogEvent serialization with subclasses
> -------------------------------------------------
>                 Key: LOG4J2-100
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-100
>             Project: Log4j 2
>          Issue Type: Improvement
>          Components: Appenders, Core
>    Affects Versions: 2.0-beta2
>            Reporter: Das Archive
>            Priority: Minor
>              Labels: patch
>         Attachments: ClassChangingAppender.java, allow_log_event_subclass_serialization.patch
> Hello!
> I am working on an extension which requires adding content to log events. As the method
of adding it to the mdc has quite some overhead and the data I want to add is not really context-related,
I was looking for an alternative and thought about subclassing Log4jLogEvent.
> But as AsynchAppender uses the Log4jLogEvent serialize/deserialize methods this didn't
> So I extended the serialize/deserialize methods to also work with subclasses.
> I'll quickly explain the the changes in the patch (in order):
> Log4jLogEvent.java:
> - not related to the improvement: ndc is never written
> - added a clone constructor to allow easy creation of subclasses Events based on Log4jLogEvents
> - make "serialize" a dynamic method as we always have an Event to serialize and it allows
overwriting the method in subclasses
> - make use of the existing "readResolve" method instead of rinventing the weel
> - LogEventProxy private -> protected to allow subclassing this inner class in subclasses
> - change all instance field from private to protected to make life easier in subclasses
> - I didn't see a reason why "readResolve" should return an Object instead of "Log4jLogEvent"
> AsynchAppender.java:
> - this is actually the only change necessary to make the changes work with the existing
> The only instance where subclassing still doesn't work (i.e. the subclass is removed)
is in the MapRewritePolicy, but I don't think this will be a big issue and apart from adding
a function to allow changing the Map in Log4jLogEvent I couldn't think of a way to solve this.
> Please note, that I haven't had the time to actually test the modified code yet!
> Best Regards,
> Das

This message was sent by Atlassian JIRA

To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org

View raw message