You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Jason B <ma...@gmail.com> on 2013/05/13 18:32:22 UTC

Convient way to specify Log4J2 configuration outside of webapp?

Hello,

I'm wondering if there is a convenient way to configure Log4J2 logging
without having it inside of our resources directory.  I don't want to use
symbolic links, as that has the potential of introducing security holes
into our platform.

We're looking into other options such as specifying file locations, but the
documentation is incomplete or does not apply to our unique solution.

Could some light be shed on this?

Thanks,

Jason Black

Re: Convient way to specify Log4J2 configuration outside of webapp?

Posted by Ralph Goers <ra...@dslextreme.com>.
No.  In that case see http://logging.apache.org/log4j/2.x/log4j-web/index.html and the Log4jContextListener.  https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk/samples/flume-remote/ has a sample web app that writes to Flume and uses the Log4jContextListener to locate its configuration.

Ralph


On May 15, 2013, at 12:57 PM, Jason B wrote:

> Ran into another interesting use case:
> 
> Suppose I have two applications that run in the same Tomcat instance.  If I
> use the -Dlog4j.configurationFile property, would I be able to specify
> individual log configurations for those applications?
> 
> 
> On Mon, May 13, 2013 at 12:13 PM, Jason B <ma...@gmail.com> wrote:
> 
>> I believe that solves that problem.  Thank you very much for your reply!
>> 
>> - Jason Black
>> 
>> 
>> On Mon, May 13, 2013 at 10:44 AM, Remko Popma <re...@yahoo.com> wrote:
>> 
>>> By default Log4j looks for log4j2.xml in the classpath, but you can also
>>> specify system property
>>> -Dlog4j.configurationFile=path/to/log4j2.xml
>>> 
>>> or even in your code:
>>> 
>>> System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "path/to/log4j2.xml");
>>> 
>>> 
>>> 
>>> ________________________________
>>> From: Jason B <ma...@gmail.com>
>>> To: log4j-user@logging.apache.org
>>> Sent: Tuesday, May 14, 2013 1:32 AM
>>> Subject: Convient way to specify Log4J2 configuration outside of webapp?
>>> 
>>> 
>>> Hello,
>>> 
>>> I'm wondering if there is a convenient way to configure Log4J2 logging
>>> without having it inside of our resources directory.  I don't want to use
>>> symbolic links, as that has the potential of introducing security holes
>>> into our platform.
>>> 
>>> We're looking into other options such as specifying file locations, but
>>> the
>>> documentation is incomplete or does not apply to our unique solution.
>>> 
>>> Could some light be shed on this?
>>> 
>>> Thanks,
>>> 
>>> Jason Black
>>> 
>> 
>> 


Re: Convient way to specify Log4J2 configuration outside of webapp?

Posted by Jason B <ma...@gmail.com>.
Ran into another interesting use case:

Suppose I have two applications that run in the same Tomcat instance.  If I
use the -Dlog4j.configurationFile property, would I be able to specify
individual log configurations for those applications?


On Mon, May 13, 2013 at 12:13 PM, Jason B <ma...@gmail.com> wrote:

> I believe that solves that problem.  Thank you very much for your reply!
>
> - Jason Black
>
>
> On Mon, May 13, 2013 at 10:44 AM, Remko Popma <re...@yahoo.com> wrote:
>
>> By default Log4j looks for log4j2.xml in the classpath, but you can also
>> specify system property
>> -Dlog4j.configurationFile=path/to/log4j2.xml
>>
>> or even in your code:
>>
>> System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "path/to/log4j2.xml");
>>
>>
>>
>> ________________________________
>>  From: Jason B <ma...@gmail.com>
>> To: log4j-user@logging.apache.org
>> Sent: Tuesday, May 14, 2013 1:32 AM
>> Subject: Convient way to specify Log4J2 configuration outside of webapp?
>>
>>
>> Hello,
>>
>> I'm wondering if there is a convenient way to configure Log4J2 logging
>> without having it inside of our resources directory.  I don't want to use
>> symbolic links, as that has the potential of introducing security holes
>> into our platform.
>>
>> We're looking into other options such as specifying file locations, but
>> the
>> documentation is incomplete or does not apply to our unique solution.
>>
>> Could some light be shed on this?
>>
>> Thanks,
>>
>> Jason Black
>>
>
>

Re: Convient way to specify Log4J2 configuration outside of webapp?

Posted by Jason B <ma...@gmail.com>.
I believe that solves that problem.  Thank you very much for your reply!

- Jason Black


On Mon, May 13, 2013 at 10:44 AM, Remko Popma <re...@yahoo.com> wrote:

> By default Log4j looks for log4j2.xml in the classpath, but you can also
> specify system property
> -Dlog4j.configurationFile=path/to/log4j2.xml
>
> or even in your code:
>
> System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "path/to/log4j2.xml");
>
>
>
> ________________________________
>  From: Jason B <ma...@gmail.com>
> To: log4j-user@logging.apache.org
> Sent: Tuesday, May 14, 2013 1:32 AM
> Subject: Convient way to specify Log4J2 configuration outside of webapp?
>
>
> Hello,
>
> I'm wondering if there is a convenient way to configure Log4J2 logging
> without having it inside of our resources directory.  I don't want to use
> symbolic links, as that has the potential of introducing security holes
> into our platform.
>
> We're looking into other options such as specifying file locations, but the
> documentation is incomplete or does not apply to our unique solution.
>
> Could some light be shed on this?
>
> Thanks,
>
> Jason Black
>

Re: Convient way to specify Log4J2 configuration outside of webapp?

Posted by Remko Popma <re...@yahoo.com>.
By default Log4j looks for log4j2.xml in the classpath, but you can also specify system property
-Dlog4j.configurationFile=path/to/log4j2.xml

or even in your code:
System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "path/to/log4j2.xml");



________________________________
 From: Jason B <ma...@gmail.com>
To: log4j-user@logging.apache.org 
Sent: Tuesday, May 14, 2013 1:32 AM
Subject: Convient way to specify Log4J2 configuration outside of webapp?
 

Hello,

I'm wondering if there is a convenient way to configure Log4J2 logging
without having it inside of our resources directory.  I don't want to use
symbolic links, as that has the potential of introducing security holes
into our platform.

We're looking into other options such as specifying file locations, but the
documentation is incomplete or does not apply to our unique solution.

Could some light be shed on this?

Thanks,

Jason Black