Panos
Panos

Reputation: 7417

Log4j Logger in Java standalone application. properties path in jar file

I want to use Log4j in my java standalone application. Where should I put my log4j.properties file so that I can distribute it with my application? Should it be located in the log4j jar or im my application's jar? Which is the correct path?

Upvotes: 0

Views: 1269

Answers (2)

Metalhead
Metalhead

Reputation: 1449

It is always advisable to put such configurations in your own packaging war or jar. This way you do not have the risk of your changes or configurations being overridden .

Conversely , the issues with packaging with other 3rd party jar's is explained by Martin.

Upvotes: 0

Martin Ellis
Martin Ellis

Reputation: 9651

Put in in your application's jar.

As a rule of thumb, you should avoid re-packing existing jars, especially third-party jars. Why?

  • If they're digitally signed in some way, then you could break the signature.
  • It won't be obvious to someone else that you've added a file to a third-party jar. If they try to upgrade it to a later version, and don't know that they need to add files to it, then they'll be very confused.
  • Re-packing jars as part of your build process is slow. But since you have to build your application jar anyway, it's cheap to add in files like log4j.properties.

Upvotes: 2

Related Questions