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

Remko Popma commented on LOG4J2-314:
------------------------------------

Sudharma, I appreciate you taking the time to create a small program that 
demonstrates the issue.
If you really need to get this fixed quickly you can always submit a patch. 
That said, I will try to work on this this weekend, but no guarantees. (We're 
all volunteers working on this in our spare time.) 

I did take a look at your code. Are trying to do the following? (please correct 
me if I'm wrong)
* you want to create Loggers dynamically at runtime
* each Logger logs to its own file, using a RollingFileAppender
* there is a RequestId string that needs to be embedded in the file name (I 
assume this string is unique)
* you would like to use asynchronous logging so you wrap the 
RollingFileAppender in an AsyncAppender and connect the AsyncAppender to the 
LoggerConfig before returning the new Logger

You may be able to get this to work (I haven't tried running your code yet), 
but how many Loggers do you expect will be created? If this is several 100s or 
even 1000s you will also end up with 1000s of threads: every AsyncAppender has 
its own thread. This approach will not scale very well.

I'm beginning to think you need a different solution. I think we should 
consider providing a multiplexing appender that logs to separate files, perhaps 
based on key-values pairs you can set in the ThreadContextMap. This would be 
similar to the SiftingAppender that LogBack provides.
                
> 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]

Reply via email to