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 <[email protected]>
> Subject: how to load an external log4j2.xml when running a standalone 
> application?
> Date: August 8, 2017 at 7:17:52 PM MST
> To: "[email protected]" <[email protected]>
> Reply-To: "Log4J Users List" <[email protected]>
> 
> 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