Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

When this method is called by a ResourceManager, it does only one thing: changes the logging level on this task manager.

Logging Abstraction

The only thing Finally, the problem left is how the logging level is changed on a job manager or task managers. Although log4j2 is the default logging implementation that is included in the distribution libraries, other logging frameworks, including log4j1 and logback, are also recommended by the documentation "How to use logging". We need to have some kind of abstraction to not directly depend on the logging implementation. Provide interfaces The following interface and classes are introduced so that not only do they suit the currently supported ones but also we can have any other logging frameworks in the futureincluding the user-defined ones.

Gliffy Diagram
macroId6ad6c7d3-09ae-42ae-9f26-0027a20240d7
displayNamelogging-abstraction-class-diagram
namelogging-abstraction-class-diagram
pagePin3

As illustrated by the class diagram above, the interface LogginerProvider is introduced where the setLogLevel() method varies among different logging implementations. The isEnabled() method is invoked during the initialization. All the LoggingProvider implementation classes, that are registered using the Java service loading facility, are tested and only the first enabled one will be used. Any subclass of the Slf4jLoggingProvider is considered to be enabled as long as the factory name returned from StaticLoggerBinder.getLoggerFactoryClassStr() is the same as the one of its logging implementation factory. If no one is enabled, NoOpLoggingProvider is used, and warning messages will be printed both duration initialization and when setLogLevel() method is called.

Supported Log Levels and Their Mappings

Here is the table of the corresponding native levels of all the supported logging implementations.

Level / ImplementationLog4jLogbackJava Logging
TRACEorg.apache.logging.log4j.Level.TRACEch.qos.logback.classic.TRACEjava.util.logging.FINEST

DEBUG

org.apache.logging.log4j.Level.DEBUGch.qos.logback.classic.DEBUGjava.util.logging.FINE
INFOorg.apache.logging.log4j.Level.INFOch.qos.logback.classic.INFOjava.util.logging.INFO
WARNorg.apache.logging.log4j.Level.WARNch.qos.logback.classic.WARNjava.util.logging.WARNING
ERRORorg.apache.logging.log4j.Level.ERRORch.qos.logback.classic.ERRORjava.util.logging.SEVERE
SEVEREorg.apache.logging.log4j.Level.ERRORch.qos.logback.classic.ERRORjava.util.logging.SEVERE
OFForg.apache.logging.log4j.Level.OFFch.qos.logback.classic.OFFjava.util.logging.OFF

...