'Logging library implementation to use with SLF4J wrapper?
We are using third party tool (xyz tool) as a war dependency in our application.
Now problem is xyz tool has its own way of logging errors - like they are putting debug logs in Dubug.log file then engine logs in engine.log file and so on. they are primarily using SLF4J with Log4j and commons-logging for other purposes as they said.
now when come to our application level logging, we are using log4j. hence what happening.. we are overriding their logging configuration as both are using log4j and we dont want their tool related logs get printed in our application logs.
so what we thought of using diff logger library but that tool already using slf4j with log4j so we can not use other libs like logback, commons-logging, java.util.logging and so on as mentioned in below snip.
we tried using logback-classic.jar but its being conflicted with log4j-slf4j-impl.jar
now i am not getting which impl to use to solve the problem.
Solution 1:[1]
What I do is have a log4j.properties with these dependencies. I think this is the simplest config. You might find this config easier than what you are trying to do.
<!--region Lombok Configuration -->
<!-- logger guide http://www.javabyexamples.com/lombok-log4j-slf4j-and-other-log-annotations#slf4j -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.15.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.15.0</version>
</dependency>
<!-- endregion -->
NOTE2: these dependencies represent the SLF4j wrapper bound to log4j logger implementation.
NOTE1: I am not 100% sure the above config will work for you. Just taking a guess.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

