Dean Hiller created LOGBACK-1473:
------------------------------------

             Summary: %caller broken for lambdas in latest alpha release
                 Key: LOGBACK-1473
                 URL: https://jira.qos.ch/browse/LOGBACK-1473
             Project: logback
          Issue Type: Bug
          Components: logback-core
    Affects Versions: 1.3.0-alpha4, 1.3.0-alpha3, 1.3.0-alpha1, 1.3.0-alpha0
         Environment: Any, easy to reproduce
            Reporter: Dean Hiller
            Assignee: Logback dev list


%caller is an amazing feature!!!  We install logback/slf4j as the defacto 
standard in [https://github.com/deanhiller/webpieces] AND more importantly, on 
the DevelopmentServer (recompiles code live as the server is running), we use 
the pattern %caller such that Developers can 'click' on any log statement and 
it takes them in their IDE right to that class file and log line.  This works 
in intellij and in Eclipse wonderfully.

So, off the branch logbackBugs, we have this class with line numbers

[https://github.com/deanhiller/webpieces/blob/logbackBugs/webserver/webpiecesServerBuilder/templateProject/WEBPIECESxAPPNAME-dev/src/main/java/WEBPIECESxPACKAGE/DevelopmentServer.java]

We have the following pattern

[https://github.com/deanhiller/webpieces/blob/logbackBugs/webserver/webpiecesServerBuilder/templateProject/WEBPIECESxAPPNAME-dev/src/main/resources/logback.xml]

which is 

%date\{ISO8601} [%thread][%X\{socket}] [%X\{txId}-%X\{user}] *%caller\{1}* 
%-4level: %message%n

The output of running that program is

2019-07-01 09:21:00,716 [main][] [-] Caller+0 at 
WEBPIECESxPACKAGE.DevelopmentServer.main(DevelopmentServer.java:17)

INFO: Starting Development Server under java version=11.0.3

2019-07-01 09:21:00,720 [main][] [-] Caller+0 at 
org.slf4j.spi.DefaultLoggingEventBuilder.logViaPublicLoggerAPI(DefaultLoggingEventBuilder.java:120)

INFO: testing out %caller\{1}

2019-07-01 09:21:00,721 [main][] [-] Caller+0 at 
org.slf4j.spi.DefaultLoggingEventBuilder.logViaPublicLoggerAPI(DefaultLoggingEventBuilder.java:120)

 

NOTICE that the first log line is correct.  Our log is from line 17 in 
DevelopmentServer.java.  The second line is logging incorrectly(ie. I 
personally think logback should adjust for this as it can tell if the lambda 
method was called or not as it already is looking at the stack trace).

We would love to upgrade to slf4j2 but this was a huge feature in using our 
DevelopmentServer.  It works like ruby where you just keep coding and never 
restart the server and COMBINED with this amazing caller feature, you can click 
any logs to go right to the log statement which has been amazing.

 

NOTES: If you like, it is very easy to run the above program yourself like so
 * git clone [https://github.com/deanhiller/webpieces.git]
 * cd webpieces
 * git checkout logbackBugs
 * import into Intellij OR Eclipse via gradle (both are tested often and work)
 * Open DevelopmentServer.java and run it

 



--
This message was sent by Atlassian JIRA
(v7.3.1#73012)
_______________________________________________
logback-dev mailing list
logback-dev@qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-dev

Reply via email to