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 Woonsan Ko <wo...@yahoo.com> on 2013/07/17 17:27:30 UTC

Lookup support for JNDI resources?

Hi,

I'd like to use RoutingAppender [1] to put all the logs from the same web application context in a log file  (a log file per web application context).

I think I can achieve almost the same feature as logback SiftingAppender [2] with that, but I have one problem.
I want to use JNDI resources look up somehow to determine the target route like logback JNDI context selector [3].
However, I couldn't find information to use lookups from JNDI resources in [4].
The reason why I prefer JNDI resources instead of MDC is that I don't have to add any code to put an MDC property in a thread and JNDI resource lookup will always work even in a separate thread without caring thread context variables.
Is there any way to achieve this with JNDI or something else? Or can it be something to improve?

Regards,

Woonsan


[1] http://logging.apache.org/log4j/2.x/manual/appenders.html#RoutingAppender
[2] http://logback.qos.ch/manual/appenders.html#SiftingAppender
[3] http://logback.qos.ch/manual/contextSelector.html
[4] http://logging.apache.org/log4j/2.x/manual/lookups.html

Re: Lookup support for JNDI resources?

Posted by Woonsan Ko <wo...@yahoo.com>.
Thanks, Ralph!
I'll be happily trying to post a patch soon in the following JIRA issue:
- https://issues.apache.org/jira/browse/LOG4J2-313

Cheers,

Woonsan





>________________________________
> From: Ralph Goers <ra...@dslextreme.com>
>To: Log4J Users List <lo...@logging.apache.org>; Woonsan Ko <wo...@yahoo.com> 
>Sent: Wednesday, July 17, 2013 11:46 AM
>Subject: Re: Lookup support for JNDI resources?
> 
>
>You would need to create a JNDILookup plugin.  This should be easy to do.  I would suggest you create a Jira issue to request this.  If you could supply the patch that would be great but if not it should be pretty easy to implement.
>
>Ralph
>
>
>On Jul 17, 2013, at 8:27 AM, Woonsan Ko wrote:
>
>> Hi,
>> 
>> I'd like to use RoutingAppender [1] to put all the logs from the same web application context in a log file  (a log file per web application context).
>> 
>> I think I can achieve almost the same feature as logback SiftingAppender [2] with that, but I have one problem.
>> I want to use JNDI resources look up somehow to determine the target route like logback JNDI context selector [3].
>> However, I couldn't find information to use lookups from JNDI resources in [4].
>> The reason why I prefer JNDI resources instead of MDC is that I don't have to add any code to put an MDC property in a thread and JNDI resource lookup will always work even in a separate thread without caring thread context variables.
>> Is there any way to achieve this with JNDI or something else? Or can it be something to improve?
>> 
>> Regards,
>> 
>> Woonsan
>> 
>> 
>> [1] http://logging.apache.org/log4j/2.x/manual/appenders.html#RoutingAppender
>> [2] http://logback.qos.ch/manual/appenders.html#SiftingAppender
>> [3] http://logback.qos.ch/manual/contextSelector.html
>> [4] http://logging.apache.org/log4j/2.x/manual/lookups.html
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
>

Re: Lookup support for JNDI resources?

Posted by Ralph Goers <ra...@dslextreme.com>.
You would need to create a JNDILookup plugin.  This should be easy to do.  I would suggest you create a Jira issue to request this.  If you could supply the patch that would be great but if not it should be pretty easy to implement.

Ralph


On Jul 17, 2013, at 8:27 AM, Woonsan Ko wrote:

> Hi,
> 
> I'd like to use RoutingAppender [1] to put all the logs from the same web application context in a log file  (a log file per web application context).
> 
> I think I can achieve almost the same feature as logback SiftingAppender [2] with that, but I have one problem.
> I want to use JNDI resources look up somehow to determine the target route like logback JNDI context selector [3].
> However, I couldn't find information to use lookups from JNDI resources in [4].
> The reason why I prefer JNDI resources instead of MDC is that I don't have to add any code to put an MDC property in a thread and JNDI resource lookup will always work even in a separate thread without caring thread context variables.
> Is there any way to achieve this with JNDI or something else? Or can it be something to improve?
> 
> Regards,
> 
> Woonsan
> 
> 
> [1] http://logging.apache.org/log4j/2.x/manual/appenders.html#RoutingAppender
> [2] http://logback.qos.ch/manual/appenders.html#SiftingAppender
> [3] http://logback.qos.ch/manual/contextSelector.html
> [4] http://logging.apache.org/log4j/2.x/manual/lookups.html


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org