Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Log4j API and SLF4J #177

Merged
merged 1 commit into from
Nov 3, 2023
Merged

Conversation

ppkarwasz
Copy link
Contributor

The logging backends supported by the default LogFactoryImpl have all reached their end-of-life (except JUL and SimpleLog). Third-generation logging backends, such as Log4j Core, support multiple logger contexts per application and therefore can not be handled by the simplified caching mechanism in LogFactoryImpl.

This PR introduces two new LogFactory implementations, Log4j2LogFactory and Slf4jLogFactory, that forward messages to the Log4j API and SLF4J respectively.

During initialization the three existing factories are checked in the following order:

  1. the Log4j2LogFactory has highest priority, since the Log4j API can faithfully transmit messages of type Object,
  2. the Slf4jLogFactory is the next choice. However, if the Log4j-to-SLF4J bridge is present we log directly to SLF4J instead of the Log4j API.
  3. the legacy LogFactoryImpl has lowest priority.

All the messages produced by loggers from Log4j2LogFactory and Slf4jLogFactory are marked with a COMMONS-LOGGING marker.

This PR also marks the old Log4jLogger class as deprecated.

The logging backends supported by the default `LogFactoryImpl` have all
reached their end-of-life (except JUL and `SimpleLog`). Third-generation
logging backends, such as Log4j Core, support multiple logger contexts
per application and therefore can not be handled by the simplified
caching mechanism in `LogFactoryImpl`.

This PR introduces two new `LogFactory` implementations,
`Log4j2LogFactory` and `Slf4jLogFactory`, that forward messages to the
Log4j API and SLF4J.

During initialization the three existing factories are checked in the
following order:
 1. the `Log4j2LogFactory` has highest priority, since the Log4j API can
    faithfully transmit messages of type `Object`,
 2. the `Slf4jLogFactory` is the next choice. However, if the
    Log4j-to-SLF4J bridge is present we log directly through SLF4J
    instead of the Log4j API.
 3. the legacy `LogFactoryImpl` has lowest priority.
@ppkarwasz
Copy link
Contributor Author

@garydgregory,

Could you take a look at this?

@garydgregory
Copy link
Member

@garydgregory,

Could you take a look at this?

@ppkarwasz
I should be able to get to it tomorrow hopefully.

@garydgregory garydgregory merged commit 946711e into apache:master Nov 3, 2023
7 checks passed
@garydgregory
Copy link
Member

TY @ppkarwasz !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants