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

[question] Log4j Version #382

Open
FabianoLothor opened this issue Dec 20, 2023 · 5 comments
Open

[question] Log4j Version #382

FabianoLothor opened this issue Dec 20, 2023 · 5 comments

Comments

@FabianoLothor
Copy link

FabianoLothor commented Dec 20, 2023

Hi @ceki

Please, what's the log4j version used when I've org.slf4j:log4j-over-slf4j:jar:1.7.10:compile as dependency?

Or at least, what's the log4j version that org.slf4j:log4j-over-slf4j:jar:1.7.10:compile is trying to mock?

Is there any page that I can use use as reference to get this information?


My question is mainly to figure out what are the Log4j features that I'm able to use based on its version.

@ceki
Copy link
Member

ceki commented Dec 20, 2023

Hi @FabianoLothor

It is log4j version 1.x that log4j-over-slf4j mocks.

The log4j-over-slf4j documentation was updated to dissipate any ambiguity.

@FabianoLothor
Copy link
Author

Thank you @ceki!

By log4j 1.x you mean that any feature available in the latest version of log4j will be also available at log5j-over-slf4j?

@FabianoLothor
Copy link
Author

The reason I'm asking is because I saw that I'm able to use %marker in the PatternLayout, which isn't available in 1.x docs, only in 2.x docs.

However, I'm not able to use %notEmpty{[%marker]}, which is also only available in 2.x docs.

I'm trying to understand what features I can and can't use.

@ceki
Copy link
Member

ceki commented Dec 21, 2023

Here is what the documentation states:

SLF4J ships with a module called log4j-over-slf4j. It allows log4j 1.x users (but not log4j 2.x) to migrate existing applications to SLF4J without changing a single line of code but simply by replacing the log4j.jar file with log4j-over-slf4j.jar, as described below.

Are you trying to migrate an existing application or library using log4j 1.x to SLF4J? That is the use case that log4j-over-slf4j.jar caters for.

@FabianoLothor
Copy link
Author

That's not the case, my application is currently using log4j-over-slf4j:1.7.x.

What I'm actually looking for is the correct documentation for my application.

I've the following dependencies:

image

I'm without answers for some questions. For example:

  • Should I look for log4j 1.x docs or logback docs while working with log4j-over-sl4j?
  • Why some features from log4j 2.x are available like %marker and others aren't like %notEmpty{[%marker]}?
    • For what I could check, log4j 1.x doesn't accept %marker. (docs)
  • What's the proper way to make LoggerFactory.getLogger() return my custom Logger instead of org.apache.log4j.Logger?
    • Note that I want to make LoggerFactory.getLogger() return my custom Logger instead of create also a CustomLoggerFactory.
  • Is it possible to change the default logger LOGGER_FACTORY_KEY? How?

I saw many examples and ways of solve some of the questions above, but there are so many versions that is complicated to figure out the best practices reading things out of the docs. Usually the answers don't come with the dependencies and versions being used.


Anyway, I'll spend more time researching, but I'm mainly trying to override the default Logger class without need to create a new LoggerFactory.

I'd like to basically wrap org.apache.log4j.Logger in my CustomLogger and bind this CustomLogger as default to my application. But I'm having a bad time trying to do that with the packages I've available.

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

No branches or pull requests

2 participants