Where to place log4j.xml

前端 未结 6 737
滥情空心
滥情空心 2020-11-30 02:37

How can we specify were log4j has to look at when trying to find its xml configuration file ?

It seems that by default, log4j looks into the root of a class folder,

6条回答
  •  执笔经年
    2020-11-30 02:50

    It finds the log4j.xml using the CLASSPATH. If log4j doesn't find any config file, it will send an error to the console. If you don't see any such error then it is likely that it is finding a config file which may not be the one you are editing. There is a command-line option to force Log4J to report the path of the config file it is using.

    From http://wiki.apache.org/logging-log4j/Log4jConfigurationHelp

    If you run with "-Dlog4j.debug" then log4j will print out info to standard output telling how it is trying to configure itself. Looking through that will tell you where it is looking for the config file.

提交回复
热议问题