log4j2 dynamic file name based on command line argument
问题 We are using a fairly simple log4j2.xml configuration file to log to stdout. However there are cases where we want to change this configuration programmatically after the start of the application to use a log file that is handed over on the command line. For this I followed the suggestion on the log4j2 homepage and wrote the following method static void divertLogging(String logFile, Level level) { ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory