This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I'm not sure if i'm in framework heck or just lost (possibly both).
The situation is this: I have an application that uses spring boot, spring boot starter log4j2, and obviously log4j2. We use spring profiles as well as gradle for building and deployment.
In my application yml I have a line like this for each profile logging.config: classpath:log4j2.local.xml
this goes to my log4j2 xml configuration, picking the correct one based on environment.
This works well, for all logging in the application.
However, I also have written a library jar this application and others need. What I want is for this library (which i can control source code on), when it is included, to log to the same place/files/configuration as the application including it.
And that is where I promptly get lost. Using log4j2 directly in the library doesn't seem to log the messages at all.
Using Apache Commons Logging in the library, when everything gets deployed, ignores the log4j2 configuration and just spits stuff to catalina.out (we're deploying to tomcat)
At this point, I'm not familiar enough with writing libraries to know the right path forward. Should i be writing the library code against JCL and get the Log4j-JCL bridge in my consuming application?
Should i just write the library code against log4j2 and i need to figure out what went wrong in that configuration that it didn't pick up the log4j2 files?
Is there a different solution like SLF4j the bridge to log4j2 I should be using instead of Apache Commons Logging?
I just need to know how to get this to work, as some of our log appenders do things like email our oncall list if things critically error.
Subreddit
Post Details
- Posted
- 7 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/javahelp/co...