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

Gary Gregory commented on LOG4J2-555:
-------------------------------------

With Bruce's patch I get:
{noformat}
Failed tests:
  RewriteAppenderTest.rewriteTest:83 Incorrect number of events. Expected 1, 
got 0
  JSONRoutingAppender2Test.routingTest:79 Incorrect number of events. Expected 
1, got 0
  JSONRoutingAppenderTest.routingTest:79 Incorrect number of events. Expected 
1, got 0
  RoutingAppenderTest.routingTest:79 Incorrect number of events. Expected 1, 
got 0
  RoutingAppenderWithJndiTest.routingTest:103 Incorrect number of events. 
Expected 1, got 0
  RoutingDefaultAppenderTest.routingTest:79 Incorrect number of events. 
Expected 1, got 0

Tests run: 539, Failures: 6, Errors: 0, Skipped: 12

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Apache Log4j 2 .................................... SUCCESS [  1.136 s]
[INFO] Apache Log4j API .................................. SUCCESS [ 47.379 s]
[INFO] Apache Log4j Core ................................. FAILURE [09:06 min]
[INFO] Apache Log4J Core OSGi Async ...................... SKIPPED
[INFO] Apache Log4J Core OSGi JPA ........................ SKIPPED
[INFO] Apache Log4j 1.x Compatibility API ................ SKIPPED
[INFO] Apache Log4J 1.x Compatibility Bundle ............. SKIPPED
[INFO] Apache Log4J Core OSGi Net ........................ SKIPPED
[INFO] Apache Log4J Core OSGi CouchDB .................... SKIPPED
[INFO] Apache Log4J Core OSGi MongoDB .................... SKIPPED
[INFO] Apache Log4J Core OSGi ............................ SKIPPED
[INFO] Apache Log4j to SLF4J Adapter ..................... SKIPPED
[INFO] Apache Log4j to SLF4J ............................. SKIPPED
[INFO] Apache Log4j SLF4J Binding ........................ SKIPPED
[INFO] Apache Log4j for SLF4J ............................ SKIPPED
[INFO] Apache Log4J Core OSGi Bundles .................... SKIPPED
[INFO] Apache Log4j Commons Logging Bridge ............... SKIPPED
[INFO] Apache Log4j Flume NG Bridge ...................... SKIPPED
[INFO] Apache Log4j Tag Library .......................... SKIPPED
[INFO] Apache Log4j JMX GUI .............................. SKIPPED
[INFO] Apache Log4j Samples .............................. SKIPPED
[INFO] Apache Log4j Samples: Flume - Common .............. SKIPPED
[INFO] Apache Log4j Samples: Flume - Remote .............. SKIPPED
[INFO] Apache Log4j Samples: Flume - Embedded ............ SKIPPED
[INFO] Apache Log4j 2 BOM ................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
{noformat}

Can you provide another patch?

> Location-based functionality broken in AbstractLoggerWrapper subclasses
> -----------------------------------------------------------------------
>
>                 Key: LOG4J2-555
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-555
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: API, Core
>    Affects Versions: 2.0-rc1
>            Reporter: Remko Popma
>            Assignee: Remko Popma
>             Fix For: 2.0-rc2
>
>         Attachments: LOG4J2-555-delegate.patch, log4j2-555-bbrouwer.patch
>
>
> *How to reproduce*
> * Create a custom logger that extends {{AbstractLoggerWrapper}} (or generate 
> one with the tool attached to LOG4J2-519)
> * In the custom logger provide a public method that invokes the {{log(Level, 
> String)}} method
> * Configure a pattern layout that uses location, like %C for the logger FQCN
> * From a sample app, call the public method on your custom logger.
> * The output will show the class name of the custom logger instead of the 
> class name of the calling class in the sample application.
> *Cause*
> {{AbstractLogger}}'s FQCN field is {{static final}} and initialized to 
> {{AbstractLogger.class.getName()}}. Then, in 
> {{Log4jLogEvent#calcLocation()}}, when walking over the stack trace elements, 
> the element _following_ the FQCN is returned. So only loggers that directly 
> subclass from {{AbstractLogger}} will work correctly. Loggers that inherit 
> from {{AbstractLoggerWrapper}} are two levels removed from {{AbstractLogger}} 
> and the {{calcLocation()}} method will not work correctly.
> *Solution*
> I think {{AbstractLogger}}'s FQCN field should be made non-static, and 
> initialized to {{getClass().getName()}} in the constructor of 
> {{AbstractLogger}}. {{Log4jLogEvent#calcLocation()}} can then be modified to 
> return the {{StackElement}} whose class name matches the FQCN, instead of the 
> next element. Location-based functionality should then work for arbitrarily 
> deep subclass hierarchies of AbstractLogger.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to