[
https://issues.apache.org/jira/browse/LOG4J2-314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13716261#comment-13716261
]
Remko Popma commented on LOG4J2-314:
------------------------------------
I'm not that familiar with how the RoutingAppender works...
Basically you want: (please correct me if I'm wrong)
* log events should be logged to a special file if and only if the
ThreadContextMap has some value for key "requestId".
* if the ThreadContextMap is empty (or does not have a value for key
"requestId") the event should be logged to the SUMMARY_ALL appender
I think this should be possible with just minor tweaks to the config I proposed
above.
Can you try defining the default route (to SUMMARY_ALL) without a key?
Like this:
{code}
<Routing name="Routing">
<Routes pattern="$${ctx:requestId}">
<Route>
<RollingFile name="Rolling-${ctx:requestId}" ... (as above)
...
</RollingFile>
</Route>
<Route appender-ref="SUMMARY_ALL" /> <!-- no key -->
</Routes>
</Routing>
{code}
If that does not work, can you try {{key="ROUTING_APPENDER_DEFAULT"}}?
Like this:
{code}
<Routing name="Routing">
<Routes pattern="$${ctx:requestId}">
<Route>
<RollingFile name="Rolling-${ctx:requestId}" ... (as above)
...
</RollingFile>
</Route>
<Route appender-ref="SUMMARY_ALL" key="ROUTING_APPENDER_DEFAULT"/>
</Routes>
</Routing>
{code}
> Multiple thread creation problem with AsyncAppender
> ---------------------------------------------------
>
> Key: LOG4J2-314
> URL: https://issues.apache.org/jira/browse/LOG4J2-314
> Project: Log4j 2
> Issue Type: Question
> Components: Appenders, Configurators
> Reporter: Sudharma Puranik
> Attachments: asyncAppendThread.png, log4j2.xml, loggerThread.png,
> TestAppender.zip
>
>
> I have a log4j2.xml configuration file from which I am getting the Logger,
> attached is the snapshot. when my logger is created a new thread is created.
> Programmatically,I create a RollingFileAppender and attach the it to
> AsyncAppender . I attach the Async Appender to the configuration of the
> log4j.xml, And when I start the Async Appender again a new thread is created.
> Is this a bug? because I get a logger a new thread is generated and when I
> create a async appender another thread is created and both are doing the same
> job.
> Also there is already a asyncappender in my log4j2.xml and I am creating one
> via program. Will this cause a problem? I did this because I am currently
> unable to hook my programmatically created appender to the AsyncAppender
> defined in log4j2.xml.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]