-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File line numbers are not printed for the failover appender when using AsyncLoggerContextSelector #3257
Comments
Hi @eldwrjwt,
Nice catch! 💯 Can you submit a PR that fixes it?
The shouldn't be a problem:
logging-log4j2/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java Line 2861 in e1715dc
logging-log4j2/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java Lines 2918 to 2920 in e1715dc
Lines 61 to 87 in 7fd3a13
In both cases the
I agree, we have the same problem as in Note that Remark: If location information is important to you, since last year we have a Log4j Transform Maven plugin, which precomputes the location of your log statements at build time. |
Hi @ppkarwasz, |
That's great! Yes, |
PR Submitted in #3259 for FailoverAppender |
Another PR #3260 for AsyncAppender |
Description
I was using a failover appender with an AsyncLoggerContextSelector and wanted to print the line number. I set includeLocation to true in the root logger, but there were still no line numbers in the logs. We encountered the same problem with the async appender, even with includeLocation set to true.
I believe this is because the requiresLocation function in FailoverAppender is the default implementation in AbstractAppender, which relies on the layout inside the appender. However, for FailoverAppender, we do not have a layout, and thus fail to generate the location field in the log event object. Additionally, the Async logger uses a RingBufferLogEvent, which directly reads the location field, so there's no location to print. This issue is also true for AsyncAppender.
Configuration
Version: 2.24.2
Operating system: Windows11
JDK: OpenJDK23
Reproduction
Log4j2.xml
log4j2.component.properties
The text was updated successfully, but these errors were encountered: