java - How to move log4j.properties outside jar file? -
i build jar file gradle, app uses log4j. log4j.properties embedded in jar file. moved outside able modify in production. updated meta-inf/manifest.mf file embedded in jar file reflect this:
class-path: lib/log4j-1.2.1 lib/slf4j-api-1.4.2.jar lib/slf4j-api-1.5.6.jar lib/slf4j-log4j12-1.5.6.jar lib/log4j-1.2.14.jar ... lib/log4j.properties my filetree follows on windows7 32bit machine:
root/myapp.jar root/lib/log4j.properties i start app command:
java -dlog4j.configuration='lib\log4j.properties' -dlog4j.debug=true -jar myapp.jar > logs/output.log my logs/output.log says log4j not find property file:
log4j: trying find ['lib\log4j.properties'] using context classloader sun.misc.launcher$appclassloader@17fa65e. log4j: trying find ['lib\log4j.properties'] using sun.misc.launcher$appclassloader@17fa65e class loader. log4j: trying find ['lib\log4j.properties'] using classloader.getsystemresource(). log4j: not find resource: ['lib\log4j.properties']. i tried with:
-dlog4j.configuration='lib/log4j.properties' -dlog4j.configuration='log4j.properties' -dlog4j.configuration=log4j.properties when embed file in jar, works:
log4j: trying find [log4j.properties] using context classloader sun.misc.launcher$appclassloader@18385e3. log4j: using url [jar:file:/c:/users/user/desktop/myapp/myapp.jar!/log4j.properties] automatic log4j configuration. log4j: reading configuration url jar:file:/c:/users/user/desktop/myapp/myapp-2.1.9.jar!/log4j.properties log4j: parsing [root] value=[debug, a]. but need outside... idea?
try this:
-dlog4j.configuration=file:lib/log4j.properties but i'm curious: class-path definition in manifest work? jars, yes, that's standard, work log4j.properties, too?
Comments
Post a Comment