[
https://issues.apache.org/jira/browse/LOG4J2-2914?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17181697#comment-17181697
]
René Link commented on LOG4J2-2914:
-----------------------------------
I have forked the repo and provided a path at
[https://github.com/link-intersystems/logging-log4j2/tree/LOG4J2-2914].
I can send you a pull request but it is only a small change.
> Kafka Producer Thread not shutdown when logging is reinitialized
> ----------------------------------------------------------------
>
> Key: LOG4J2-2914
> URL: https://issues.apache.org/jira/browse/LOG4J2-2914
> Project: Log4j 2
> Issue Type: Bug
> Components: Appenders
> Affects Versions: 2.13.3
> Reporter: René Link
> Priority: Major
> Attachments: maven-project-to-reproduce.zip
>
>
> I define a KafkaAppender, e.g. Named "Kafka", in the configuration and on
> startup of my application the logging configuration is initialized. Thus a
> Kafka producer thread exists.
> When I now reconfigure the logging programmatically later and the new
> configuration also contains a KafkaAppender named "Kafka" the old Kafka
> producer is not shut down.
> After the new configuration is initialized two Kafka producer threads exist,
> but only 1 KafkaAppender was defined in the new configuration. Thus the old
> one has not been shut down.
>
>
> I have attached a zipped maven project to reproduce the problem.
> When you execute the Main class
> {{Logger logger = LogManager.getLogger(Main.class); }}
> {{// logging initialized}}
> {{ printKafkaThreads();}}
> {{ // reinitialize }}
> {{Configurator.initialize(null, Main.class.getClassLoader(),
> "log4j2-reinitialized.xml");}}
> {{ printKafkaThreads();}}
> {{you will see the output}}
> {{======================}}
> {{Thread[kafka-producer-network-thread | producer-1,5,main]}}
> {{======================}}
> {{======================}}
> {{Thread[kafka-producer-network-thread | producer-2,5,main]}}
> {{Thread[kafka-producer-network-thread | producer-1,5,main]}}
> {{======================}}
> {{I guess the problem is that the KafkaAppender starts the KafkaManager and
> the KafkaManger does not check if the producer is already started. So it
> overrides it and therefore forgets the reference and thus can not shutdown
> the lose producer anymore.}}
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)