Hi Log4j2 Team, My query is related to log4j2 working and uses of LogManager.getLogger(String name); method.
My use case is that my application uses the above mentioned method to get logger and log. Appender and Logger have been set in log4j2.xml file. We stop the Logger by getting all core appenders , removing them , then stopping them and then using the LogManager.shutdown() method. The issue or anomaly arises when an update batch script starts the new instance of the same application and the old instance takes some time to exit, resulting in new instance getting the same logger using LogManager.getLogger("AppName"); and writing in the same log file. Once the 1st/old instance exists after a few seconds, it closes all the logging and nothing on the file gets written even when the 2nd/new instance is still up and running. Above mentioned scenario's work around is if we don't remove/stop all appenders and don't use shutdown() method, but is there any more graceful handling which can be done? The second question to this issue Is there any solution if multiple instances of the same application which are agnostic to each other's existence, use GetLogger("SameName"); and log into files with names in incremental id appended dynamically. For Example App Inst1 when gets logger, log into MyLogFile1 and when Inst2 initiates it logs into MyLogFile2. Kindly advise what can be done to handle this type of scenario when there is no communication between the instances and are totally independent and agnostic of each other. Regards, Danish Arif