We have a huge application using our custom RollingFileAppender (extended from org.apache.log4j.RollingFileAppender in log4j 1.x). We have overridden few methods, but two major methods are rollOver() and subAppend() as follows:
public void rollOver()
{
// Custom Code to specify how rolled-over files should be numbered and which file should be
// overwritten when MaxBackupIndex is reached
}
public void subAppend(LoggingEvent event)
{
// Custom Code to encrypt message before writing it
String data = this.layout.format(event);
if (isEncryptionOn())
{
data = PlatformEncryptDecrypt.encrypt2Way(data);
data = toUnicodeHexString(data);
}
this.qw.write(data);
.
.
.
// Other code taken from parent class
.
.
.
}
While migrating this to log4j2, I want to leverage log4j2's RollingFileAppender as much as possible, while overriding only selected methods. Since RollingFileAppender is final class, I would prefer to use builder for creating custom appender. I went through few other similar posts, but they are talking about logging few extra attributes with RollingFileAppender.
What would be the best way to achieve this using current latest version of log4j2 i.e. 2.13? Any help is highly appreciated.