I am writing a custom wrapper over log4j2. Using https://logging.apache.org/log4j/2.x/manual/customloglevels.html#CustomLoggers
The requirement was to choose the appender based on the object type being logged. The approach I am thinking was to extend the log4j2 logger and override log methods(like info), In those methods, check the object type and call the required appender.
Now I want my application to use slf4j facade instead of log4j2 directly. Need help on how to bind my custom log4j2 wrapper to slf4j, with less effort :)
One option I am thinking(haven't tried yet) is to refer my customlogger wrapper in log4j-slf4j-impl and generate jar and use the same in application, https://github.com/apache/logging-log4j2/blob/f838bd6f42ea104e692e9e2227dcc54283a41901/log4j-slf4j18-impl/src/main/java/org/apache/logging/slf4j/Log4jLogger.java
- Do we have any better approach to solve this problem?