Reputation: 41
we were earlier using Log4j in our application. we knew that some of the errors are logged are not actual errors. These logs are not directly from application but from some of the dependent jars. One option would be to downgrade all the errors from specified class. But we don't want to do that as the blast radius was more. We looked for specifically if the the logging msg from the class is not actual error then we downgraded the error to info. Now we have upgraded to log4j2 and are trying to find equivalent to this.
Here is the logic in log4j
TestRollingFileAppender extends DailyRollingFileAppender {
@Override
protected void subAppend(LoggingEvent event) {
if (event.getLevel().isGreaterOrEqual(Level.WARN)) {
//stringsToDowngrade reads from properties file and gets set of msgs that can be downgraded
String[] testSubstrings = stringsToDowngrade(event.getLogger());
for (String testString : testSubstrings) {
if (event.getMessage() != null &&
StringUtils.isNotBlank(testString) &&
event.getMessage().toString().contains(testString)) {
event = new LoggingEvent(...,LEVEL.WARN,...);
break;
}
}
}
}
Upvotes: 1
Views: 705
Reputation: 9141
You have a couple of choices.
Upvotes: 2