The problem you are experiencing is that the command line shell is not treating 
log4j.configurationFile as a variable name. Try putting it in single quotes.

Ralph

> Begin forwarded message:
> 
> From: LV XIAOYI <bgl...@hotmail.com>
> Subject: how to load an external log4j2.xml when running a standalone 
> application?
> Date: August 8, 2017 at 7:17:52 PM MST
> To: "log4j-user@logging.apache.org" <log4j-user@logging.apache.org>
> Reply-To: "Log4J Users List" <log4j-user@logging.apache.org>
> 
> Hi all,
> 
> 
> I have an executable jar, and I run it with this command:
> 
> 
> java -jar .\my.jar
> 
> 
> if  log42j.xml in my.jar, it is working,  if log42.xml out of   my.jar, it is 
> not working.
> 
> 
> I try  the “-Dlog4j.configurationFile”  to load log4j2.xml like this:
> 
> 
> java -Dlog4j.configurationFile=.\log4j2.xml -jar .\ubbp-scheduled-1.0.2.jar
> 
> 
> then it shows erros:
> 
> 
> ERROR: cannot find or load the main class  .configurationFile=.\log4j2.xml.
> 
> 
> it seems that the -D option cannot apply to the command: java -jar.
> 
> 
> So, is there anyway to load an external log4j2.xml when running a standalone 
> application?

Reply via email to