1

I have one customer appender class that was implemented in log4j 1 as below:

import org.apache.log4j.FileAppender;
import org.apache.log4j.helpers.CountingQuietWriter;
import org.apache.log4j.helpers.LogLog;
...

public class CustomFileAppender extends FileAppender
{
    ...
    @Override
    protected void setQWForFiles(final Writer writer)
    {
        super.qw = new CountingQuietWriter(writer, super.errorHandler);
    }
}

I'm trying to migrate this class to use bridge (log4j-1.2-api-2.17.1) (and log4j 2 core and api version 2.17.1)

I noticed that:

1> The Log4j bridge does not have FileApennder class. The migration doc did list the FileAppender as one of the supported components

2> log4j 2 File appender cannot be extend as the class is defined as "public final class FileAppender"

My questions are:

1> What is the best way to migrate custom File Appender in this case?

2> What is the equivalent of below classes in log4j2?

  • org.apache.log4j.FileAppender;
  • org.apache.log4j.helpers.CountingQuietWriter
  • org.apache.log4j.helpers.LogLog
someone_ smiley
  • 1,006
  • 3
  • 23
  • 42

1 Answers1

0

log4j2 and the bridge do not contain the classes that log4j1 custom appenders used to extend, therefore you must consider rewriting your custom appender as a new log4j2 plugin. You can get some information from here and here. This post also can give you some inspiration.

pouyan021
  • 177
  • 1
  • 4
  • 19
  • Version 2.17.2 will contain about 50 improvements in the Log4j 1.x bridge, among them some old classes like `org.apache.log4j.FileAppender`. – Piotr P. Karwasz Feb 24 '22 at 08:51