Should log4.properties be on the classpath?

前端 未结 6 1315
清酒与你
清酒与你 2020-12-01 16:55

I\'m having some problems putting my log4j.properties file on classpath. I can use it when I\'m developing (Eclipse Indigo) but, when I export my app as a JAR, I can\'t.

相关标签:
6条回答
  • 2020-12-01 17:36

    try to execute:

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

    0 讨论(0)
  • 2020-12-01 17:40

    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.

    0 讨论(0)
  • 2020-12-01 17:44

    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
    
    0 讨论(0)
  • 2020-12-01 17:44

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

    0 讨论(0)
  • 2020-12-01 17:51

    Add log4j.properties to app.jar.

    0 讨论(0)
  • 2020-12-01 17:56

    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.

    0 讨论(0)
提交回复
热议问题