1. 程式人生 > >程式啟動時log4j報錯 No Log4j 2 configuration file found

程式啟動時log4j報錯 No Log4j 2 configuration file found

ERROR StatusLogger No Log4j 2 configuration file found. 
Using default configuration (logging only errors to the console), 
or user programmatically provided configurations. 
Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. 
See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2

確實log4j2.xml不在類路徑下,但有在啟動指令碼有設定log4j2.xml的路徑

java -jar ServerStart.jar -Dlog4j.configurationFile=conf/log4j2.xml

原來引數需要設定在 ServerStart.jar的前面

改為

java -jar -Dlog4j.configurationFile=conf/log4j2.xml ServerStart.jar
就好了