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 "Gary Gregory (JIRA)" <ji...@apache.org> on 2015/06/23 10:18:00 UTC

[jira] [Comment Edited] (LOG4J2-1028) Incorrect Line Number in location information

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

Gary Gregory edited comment on LOG4J2-1028 at 6/23/15 8:17 AM:
---------------------------------------------------------------

Stefan,

The new patch applies cleanly, thank you for the refresh.

Unfortunately, as I mentioned previously \[1], the patch causes some tests to fail. Each failing test should be reviewed carefully to determine if the test should be changed or if the patch is really valid.

In the Core module:

{noformat}
Failed tests:
  AsyncAppenderTest.rewriteTest:75 Expected org.apache.logging.log4j.core.appender.AsyncAppenderTest rewriteTest This is a test, Actual org.apache.logging.log4j.spi.AbstractLogger logMessage This is a
 test
  MemoryMappedFileAppenderLocationTest.testMemMapLocation:75 Shrunk to actual used size expected:<478> but was:<356>
  AsyncLoggerConfigTest.testAdditivity:62 location
  AsyncLoggerLocationTest.testAsyncLogWritesToLog:68 has location
  Rfc5424LayoutTest.testLoggerFields:336 No class/method
  Rfc5424LayoutTest.testMDCLoggerFields:289 No class/method
  CallerInformationTest.testClassLogger:44 Incorrect caller class name. expected:<...pache.logging.log4j.[core.pattern.CallerInformationTest]> but was:<...pache.logging.log4j.[spi.AbstractLogger]>
  CallerInformationTest.testMethodLogger:60 Incorrect caller method name. expected:<[testMethodLogger]> but was:<[logMessage]>
  NoConsoleNoAnsiTest.testReplacement:58 Replacement failed - expected ending ERROR LoggerTest o.a.l.l.c.p.NoConsoleNoAnsiTest org.apache.logging.log4j.core.pattern.NoConsoleNoAnsiTest
, actual 2015-06-23 01:12:25,330 ERROR LoggerTest o.a.l.l.s.AbstractLogger org.apache.logging.log4j.core.pattern.NoConsoleNoAnsiTest

  StyleConverterTest.testReplacement:59 Replacement failed - expected ending ←[1;31mERROR←[m ←[1;36mLoggerTest←[m o.a.l.l.c.p.StyleConverterTest org.apache.logging.log4j.core.pattern.StyleConverterTes
t
, actual 2015-06-23 01:12:31,475 ←[1;31mERROR←[m ←[1;36mLoggerTest←[m o.a.l.l.s.AbstractLogger org.apache.logging.log4j.core.pattern.StyleConverterTest


Tests run: 764, Failures: 10, Errors: 0, Skipped: 29
{noformat}

Thank you,
Gary

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


was (Author: garydgregory):
Stefan,

The new patch applies cleanly, thank you for the refresh.

Unfortunately, as I mentioned previously [1], the patch causes some tests to fail. Each failing test should be reviewed carefully to determine if the test should be changed or if the patch is really valid.

Thank you,
Gary

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

> Incorrect Line Number in location information
> ---------------------------------------------
>
>                 Key: LOG4J2-1028
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1028
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.3
>         Environment: Java 1.8.0_45 64-bit
> Maven 3.3.1
> Windows 7
> basically any...
>            Reporter: Stefan Leonhartsberger
>         Attachments: logLinePatch.diff
>
>
> When enabling location information in Log4j2
> The line numbers of the log records are incorrect 
> as they are only taking into account the first time in the stacktrace where the 
> class in question (FQCN) was called
> This however may not be accurate as the class may call methods within itself  adding to the stacktrace - these are not considered when gathering location information within Log4jLogEvent.
> An example stacktrace:
> {code}
> stackTrace = {java.lang.StackTraceElement[18]@4612} 
>  0 = {java.lang.StackTraceElement@4617} "java.lang.Thread.getStackTrace(Thread.java:1552)"
>  1 = {java.lang.StackTraceElement@4618} "org.apache.logging.log4j.core.impl.Log4jLogEvent.calcLocation(Log4jLogEvent.java:386)"
>  2 = {java.lang.StackTraceElement@4619} "org.apache.logging.log4j.core.async.AsyncLogger.location(AsyncLogger.java:293)"
>  3 = {java.lang.StackTraceElement@4620} "org.apache.logging.log4j.core.async.AsyncLogger.logMessage(AsyncLogger.java:252)"
>  4 = {java.lang.StackTraceElement@4621} "org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:738)"
>  5 = {java.lang.StackTraceElement@4622} "org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:708)"
>  6 = {java.lang.StackTraceElement@4623} "com.test.logging.factory.Log4j2Factory$Log4J2CatsLogger.log(Log4j2Factory.java:106)"
>  7 = {java.lang.StackTraceElement@4624} "com.test.agent.configuration.Configuration.setPttId(Configuration.java:1079)"
>  8 = {java.lang.StackTraceElement@4625} "com.test.agent.configuration.Configuration.loadDefaultConfiguration(Configuration.java:323)"
>  9 = {java.lang.StackTraceElement@4614} "com.test.agent.configuration.Configuration.<init>(Configuration.java:302)"
>  10 = {java.lang.StackTraceElement@4613} "com.test.agent.configuration.ConfigurationParser.createConfig(ConfigurationParser.java:51)"
>  11 = {java.lang.StackTraceElement@4626} "com.test.agent.AgentMain.initConfig(AgentMain.java:231)"
>  12 = {java.lang.StackTraceElement@4627} "com.test.agent.AgentMain.init(AgentMain.java:204)"
>  13 = {java.lang.StackTraceElement@4628} "com.c4i.test.agent.AgentBase.init(AgentBase.java:456)"
>  14 = {java.lang.StackTraceElement@4629} "com.test.agent.AgentBase.createAgent(AgentBase.java:194)"
>  15 = {java.lang.StackTraceElement@4630} "com.test.agent.AgentBase.agentmain(AgentBase.java:141)"
>  16 = {java.lang.StackTraceElement@4631} "com.test.agent.AgentMain.main(AgentMain.java:109)"
>  17 = {java.lang.StackTraceElement@4632} "com.test.agent.AgentMain.main(AgentMain.java:86)"
> {code} 
> Expected Line Number: 1079
> Received Line Number: 302
> Reason is that the stack is iterated from the wrong direction - i=17. (starting with i=0 would result in the correct behaviour.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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