Updated specific locations to be searchable, take a look at Las Vegas as an example.

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.

2
Lost with Library Logging, how do I get everything to the same log4j2 configuration?
Post Body

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.

Author
Account Strength
60%
Account Age
9 years
Verified Email
No
Verified Flair
No
Total Karma
657
Link Karma
206
Comment Karma
368
Profile updated: 1 day ago
Posts updated: 8 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
7 years ago