'Is there a way to change the path of the RollingFile Appender programmatically in log4j

I am configuring log4j delegate programmatically and it works. I am creating RollingFileAppender as following :

    AppenderComponentBuilder rollingFile = builder.newAppender("rolling", "RollingFile");
    rollingFile.addAttribute("fileName", "C:\\codes\\logs\\rolling.log");
    rollingFile.addAttribute("filePattern", "rolling-%d{MM-dd-yy}.log.gz");
    rollingFile.add(layoutBuilder);
    rollingFile.addComponent(triggeringPolicy);

The requirement is now to update the path of the rolling file appender to a different path.

How is this possible ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source