Log4j2 - software permutation of the log file

We are currently updating log4j1 to log4j2. In our project, we have the code log4j1, which programmatically remakes the log file by calling less than two methods together

  • setAppend (false);
  • activateOptions ();

What is the equivalent option in log4j2 ?. Below is a sample code?

class TestAppender extends RollingFileAppender {
   public void m1(){
      setAppend(false); 
      activateOptions();
   }
}



  class Test{
    public void callm1(){
    TestAppender ta = new TestAppender();
    ta.m1();

    }

log4j.properties

# Define the root logger with appender file
log4j.rootLogger = DEBUG, FILE

# Define the file appender
log4j.appender.FILE= com.test.**TestAppender**
log4j.appender.FILE.File=${log}/log.out

# Define the layout for file appender
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.conversionPattern=%m%n

This code works fine now, and we need the log4j2 configuration.

Can anyone ask for log4j2 code for the above m1 method

Thank you Durga

0
source share

All Articles