Should log4.properties be on the classpath?

耗尽温柔 提交于 2019-11-27 14:28:22

Do not put the log4j.properties itself in the classpath, but the directory that contains that file.

Class-Path: lib lib/log4j-1.2.15.jar

one more way to do this: -Dlog4j.configuration=file:"./log4j.properties"

钮玉晓

There are three ways l know.

  1. Add log4j.properties to app.jar
  2. Put the log4j.properties to the "folder" (where the JAR exists) and change the class-path to .lib/log4j-1.2.15.jar.
  3. Put the log4j.properties to the folder named "conf" for example, and change the class-path to ./conf/.

I have tried, it works.

Add log4j.properties to app.jar.

I tried the answer of Jesper, and at first it didn't work. Then I tried with

Class-Path: lib/ lib/log4j-1.2.15.jar

And it worked after that.

try to execute:

javar -jar -Dlog4j.configuration=file:"./log4j.properties" app.jar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!