eldwrjwt opened a new issue, #3257:
URL: https://github.com/apache/logging-log4j2/issues/3257

   ## 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
   `
   <Configuration>
       <Appenders>
           <Console name="CONSOLE">
               <PatternLayout pattern="%m%L%n"/>
           </Console>
   
           <Console name="CONSOLE2">
               <PatternLayout pattern="%m%L%n"/>
           </Console>
   
           <Failover name="Failover" primary="CONSOLE">
               <Failovers>
                   <AppenderRef ref="CONSOLE2"/>
               </Failovers>
           </Failover>
       </Appenders>
       <Loggers>
           <Root level="INFO" includeLocation="true">
               <AppenderRef ref="Failover"/>
           </Root>
       </Loggers>
   </Configuration>
   `
   
   log4j2.component.properties
   `
   
Log4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
   `
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to