1

I am working on upgrading log4j from 1.2 to 2.8. On upgrading the dependencies and adding necessary bridges, I face the following error:

error: cannot find symbol
[javac] String name = event.getRenderedMessage(); 

error: cannot find symbol
[javac] String name = event.getLoggerName();
                           ^

On further digging the LoggingEvent provided by the log4j-1_2 api does not have any methods: http://logging.apache.org/log4j/2.x/log4j-1.2-api/apidocs/src-html/org/apache/log4j/spi/LoggingEvent.html

My code looks like:

appender.addFilter(new Filter() {
     @Override
     public int decide(LoggingEvent event){
           ///some logic
           String message = event.getRenderedMessage();
           String name = event.getLoggerName();
           ///return int based on logic including 'name' and 'message'
     }
});

Is there any alternative that I can use here? Instead of LoggingEvent or Filter?

Gastly Yoi
  • 73
  • 1
  • 8
  • I think it is worth having a look at the answer https://stackoverflow.com/a/29597669/2199826 and it is exactly the problem stated above. – Naveen Sep 25 '19 at 14:25
  • Your question seems like it could be an [XY Problem](https://meta.stackexchange.com/a/66378). Can you please tell us why you are using programmatic configuration rather than using a configuration file? – D.B. Sep 26 '19 at 04:33

0 Answers0