You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Ralph Goers (JIRA)" <ji...@apache.org> on 2013/01/15 08:56:13 UTC

[jira] [Commented] (LOG4J2-151) Please facilitate subclassing Logger and LoggerContext (in org.apache.logging.log4j.core)

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

Ralph Goers commented on LOG4J2-151:
------------------------------------

I'd love the see the code you are going to use to create the asynchronous logger. I'm wondering how you are going to handle the ThreadContext and call stack without "serializing" LogEvent.  (Note that the LogEvent really isn't serialized in the asyncAppender - it is just converted into a LogEventProxy which causes all the fields to be populated).  It also will mean that the application can't ever be informed that logging has failed - which is certainly acceptable in many use cases.
                
> Please facilitate subclassing Logger and LoggerContext (in org.apache.logging.log4j.core)
> -----------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-151
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-151
>             Project: Log4j 2
>          Issue Type: New Feature
>          Components: Core
>    Affects Versions: 2.0-beta3
>            Reporter: Remko Popma
>
> I would like to create a custom logger, while reusing the org.apache.logging.log4j.core.Logger functionality.
> The following two changes would make subclassing possible:
> * change visibility of method Logger$PrivateConfig#logEvent(LogEvent) (line 265) from protected to public
> * change visibility of method LoggerContext#newInstance(LoggerContext, String) (line 310) from private to protected
> My use case is that I want to create an asynchronous Logger for low latency logging.
> This custom logger hands off control to a separate thread as early as possible. In my case, AsynchAppender is not a good match for my requirements, as with that approach (a) the logging call still needs to flow down the hierarchy to the appender, doing synchronization and creating objects at various points on the way, and (b) when serializing the LogEvent, the getSource() method is always called, which is expensive.

--
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-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org