I am developing a java application which communicates with lots of devices. For each device I need to create a different log file to log it\'s communication with device. This is
The approach log4j2 is initialize programmatically and later configuration is modified is different. And you you trying to add dynamic appender and logger using initialization approach.
So, first you should initialize your RootLogger using initialization approach that seems correct in your code.
After that, add dynamic appender and logger using approach mentioned here