how to load an external log4j2.xml when running a standalone application?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

how to load an external log4j2.xml when running a standalone application?

LV XIAOYI
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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Fwd: how to load an external log4j2.xml when running a standalone application?

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

Loading...