How can I change the AppenderRef Level in log4j2 programmatically?
问题 How can I change the AppenderRef Level in log4j2? There is a stackoverflow question (with answer) where this was solved non-programmatically. I want the same but programmatically instead. There is only a get method in AppenderRef to retrieve the Level but no method to set it. So, is there any way to set the Level in the AppenderRef in log4j2 programmatically? 回答1: You have to do it by removing the appender and then adding it again with the desired level. Example log4j2.xml: <?xml version="1.0