[ https://issues.apache.org/jira/browse/LOG4J2-1025?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14554967#comment-14554967 ]
Gary Gregory commented on LOG4J2-1025: -------------------------------------- A smarter converter, perhaps a subclass of {{DefaultLevelConverter}} could map the custom level's int to the closest JUL level and map from there. This would be a "rounding" converter. I am not sure if this functionality should be in the {{DefaultLevelConverter}}. Another option would be for a client app to call some Log4j class to register custom levels, that seems like going to deep into Log4j code so this could be done through configuration. This would still not handle "unknown" custom levels. So a "dynamic rounding level converter" sounds like the best solution. Whether or not this should be built in to the {{DefaultLevelConverter}} or in a new {{DynamicRoundingLevelConverter}} class is the question. Thoughts? Patches? Gary > Custom java.util.logging.Level gives null Log4j Level > ----------------------------------------------------- > > Key: LOG4J2-1025 > URL: https://issues.apache.org/jira/browse/LOG4J2-1025 > Project: Log4j 2 > Issue Type: Bug > Components: JUL adapter > Affects Versions: 2.3 > Reporter: Mikael Ståldal > > I use a 3rd party library which uses custom non-standard > java.util.logging.Level. > The Log4j JUL adapter will emit log event with level set to null in that > case, which causes NullPointerException in a Log4j filter further on. > This is not acceptable. When encountering an unrecognised JUL Level, the JUL > adapter should either: > - emit some default Log4j Level > - throw an Exception with a clear error message immediately > - silently discard the log event > - discard the log event and log a warning to the StatusLogger > {code} > java.lang.NullPointerException > at org.apache.logging.log4j.Level.isMoreSpecificThan(Level.java:163) > at > org.apache.logging.log4j.core.filter.BurstFilter.filter(BurstFilter.java:129) > at > org.apache.logging.log4j.core.filter.BurstFilter.filter(BurstFilter.java:101) > at > org.apache.logging.log4j.core.Logger$PrivateConfig.filter(Logger.java:295) > at org.apache.logging.log4j.core.Logger.isEnabled(Logger.java:122) > at > org.apache.logging.log4j.spi.ExtendedLoggerWrapper.isEnabled(ExtendedLoggerWrapper.java:87) > at > org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:699) > at > org.apache.logging.log4j.jul.WrappedLogger.log(WrappedLogger.java:50) > at org.apache.logging.log4j.jul.ApiLogger.log(ApiLogger.java:106) > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org