Checking configuration files inside jars

DZone 's Guide to

Checking configuration files inside jars

· Java Zone ·
Free Resource

Are you habit to have some configuration files packaged inside the jar of your application?

If so, you can still have a look at those configuration files in the running environment using the unzip Unix utility.

$ unzip -p /opt/myapp/lib/my-app.jar log4j.properties

log4j.appender.stdout.layout.ConversionPattern=%d{dd-MMM hh:mm} [%-5p] %m%n

The -p option uncompress and prints the file content to standard output.

I like to include resource files in the deployable artifact, unless I want those files to be modifiable without repackaging. Hiding most of configuration helps to keep things simpler for the end user, but still those files can be accessed for the technical support.

By the way, the above log4j configuration is the one I used to replace some System.out/System.err in a simple command line based application. I was thinking to remove the date part ‘%d{dd-MMM hh:mm}’ and make it look like the output of ant/maven, but then I thought that -after all- the date is quite useful since the application in question is ran by cron redirecting the standard out into a file, so we keep that as a log of the last run, to have some clue in case of errors.

From http://en.newinstance.it/2011/06/01/checking-configuration-files-inside-jars/


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}