log4j.properties not picked up from jar

后端 未结 4 2046
悲&欢浪女
悲&欢浪女 2020-12-11 17:15

I have a jar in the classpath of my server which contains the log4j.properties file on root of the jar for logging of the code. When the code in the jar runs the logging for

相关标签:
4条回答
  • 2020-12-11 17:54

    The properties file is picked up from the jar based on the order in which the jar is found in classpath by your application server. Now there is no way to conclusively tell the jar from which the properties file is to be loaded.

    To get around this problem most projects include your log4j.properties file in the server classpath itself. This way this file is the first properties file to be loaded and this is the one which your logging code gets.

    0 讨论(0)
  • 2020-12-11 17:57

    I'm note quite sure but it could be an order problem. Whichever log4j.properties is loaded first/last would win (I'd have to check that).

    0 讨论(0)
  • 2020-12-11 18:06

    Possibly because axis-ant.jar comes before in classpath the your own jar. I assume putting your jar before in classpath then axis-ant.jar should help

    0 讨论(0)
  • 2020-12-11 18:07

    You should have a look at the log4j manual. The section "Default Initialization Procedure" describes how log4j will try to find the initialization file and explains possibilities to match a special configuration (e.g. by setting the system property log4j.configuration).

    If you do not want to do any special configuration you have to ensure that your configuration file will be the first one found on the classpath.

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