Skip to content
Advertisement

log4j2 change Rolling file appender max files programmatically

I am working on an application that uses log4j2 (initializes the parameters using log4j2.xml) and loads the logger. When the application runs, I am required to programmatically override a few parameters such as changing the log level and rolling file appender properties. I am able to change the log level using

JavaScript

Now I tried to tackle the same problem using RollingFile appender’s properties. However, I am stuck on how to modify the existing RollingFile appender’s property

JavaScript

What is the way to proceed with modifying the rolling file appender programmatically?

Advertisement

Answer

You are on the right track. After creating the new Strategy do:

JavaScript

If you want to modify all the RollingFileAppenders then do:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement