How to specify a log4j2.xml config file outside from classpath?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to specify a log4j2.xml config file outside from classpath?

Fröstl, Christian
Hello everybody,

We like to use a log4j2.xml file for log4j2 configuration of our hybris application.
If the file log4j2.xml is part of the classpath and the property "log4j2.config.xml=hybris-log4j2.xml" is part of my local.properties file, it will be loaded automatically and everything is fine.
But how can we load the file if it is located in a directory outside the classpath?

I tried the following:
1.Specify the absolute path in local.properties file
-> Will just get many context loader and nullpointer exceptions in logfile

2. Specify the log4j.configurationFile property in log4j2.component.properties
-> The file will be found by the system, but config will have no effect. Fallback custom log will be used

I found this documentation, that it should be possible to configure the xml file with this properties, but it doesn't work.
https://logging.apache.org/log4j/2.0/faq.html -> How do I specify the configuration file location?

Does anyone have an idea to solve this problem?

Thanks and greetings,
Christian


On 23.01.18, 17:44, "Greg Huber" <[hidden email]> wrote:

    Hello,

    In a tomcat environment how do I get Log4jServletContextListener
    contextDestroyed to be called last.  It is being called before my
    contextDestroyed and I get no logging on shutdown.

    Cheers Greg



________________________________

This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: How to specify a log4j2.xml config file outside from classpath?

Ralph Goers
I’d have to look at the code to be sure, but you might try configuring it as a url - file:///mypath <file:///mypath>.

Ralph

> On Jan 24, 2018, at 5:46 AM, Fröstl, Christian <[hidden email]> wrote:
>
> Hello everybody,
>
> We like to use a log4j2.xml file for log4j2 configuration of our hybris application.
> If the file log4j2.xml is part of the classpath and the property "log4j2.config.xml=hybris-log4j2.xml" is part of my local.properties file, it will be loaded automatically and everything is fine.
> But how can we load the file if it is located in a directory outside the classpath?
>
> I tried the following:
> 1.Specify the absolute path in local.properties file
> -> Will just get many context loader and nullpointer exceptions in logfile
>
> 2. Specify the log4j.configurationFile property in log4j2.component.properties
> -> The file will be found by the system, but config will have no effect. Fallback custom log will be used
>
> I found this documentation, that it should be possible to configure the xml file with this properties, but it doesn't work.
> https://logging.apache.org/log4j/2.0/faq.html -> How do I specify the configuration file location?
>
> Does anyone have an idea to solve this problem?
>
> Thanks and greetings,
> Christian
>
>
> On 23.01.18, 17:44, "Greg Huber" <[hidden email]> wrote:
>
>    Hello,
>
>    In a tomcat environment how do I get Log4jServletContextListener
>    contextDestroyed to be called last.  It is being called before my
>    contextDestroyed and I get no logging on shutdown.
>
>    Cheers Greg
>
>
>
> ________________________________
>
> This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

Reply | Threaded
Open this post in threaded view
|

Re: How to specify a log4j2.xml config file outside from classpath?

Tungathurthi, Chandra Kiran Bharadwaj
It's log4j.configurationFile use this property to specify external config.
As in,

`log4j.configurationFile=/path/to/log4j2.xml`




On Wed, Jan 24, 2018 at 6:47 PM +0530, "Ralph Goers" <[hidden email]<mailto:[hidden email]>> wrote:


I’d have to look at the code to be sure, but you might try configuring it as a url - file:///mypath .

Ralph

> On Jan 24, 2018, at 5:46 AM, Fröstl, Christian  wrote:
>
> Hello everybody,
>
> We like to use a log4j2.xml file for log4j2 configuration of our hybris application.
> If the file log4j2.xml is part of the classpath and the property "log4j2.config.xml=hybris-log4j2.xml" is part of my local.properties file, it will be loaded automatically and everything is fine.
> But how can we load the file if it is located in a directory outside the classpath?
>
> I tried the following:
> 1.Specify the absolute path in local.properties file
> -> Will just get many context loader and nullpointer exceptions in logfile
>
> 2. Specify the log4j.configurationFile property in log4j2.component.properties
> -> The file will be found by the system, but config will have no effect. Fallback custom log will be used
>
> I found this documentation, that it should be possible to configure the xml file with this properties, but it doesn't work.
> https://logging.apache.org/log4j/2.0/faq.html -> How do I specify the configuration file location?
>
> Does anyone have an idea to solve this problem?
>
> Thanks and greetings,
> Christian
>
>
> On 23.01.18, 17:44, "Greg Huber"  wrote:
>
>    Hello,
>
>    In a tomcat environment how do I get Log4jServletContextListener
>    contextDestroyed to be called last.  It is being called before my
>    contextDestroyed and I get no logging on shutdown.
>
>    Cheers Greg
>
>
>
> ________________________________
>
> This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>