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 Clément Guillaume <cg...@hotpads.com> on 2015/07/14 05:24:46 UTC

Print the LoggerContext name

Is it possible to print the LoggerContext name in the output?

Clément

Re: Print the LoggerContext name

Posted by Clément Guillaume <cg...@hotpads.com>.
This was not working because my web.xml was setting absolute-ordering and
so the Log4jServletContainerInitializer was never called.

On Tue, Jul 21, 2015 at 11:07 AM, Clément Guillaume <cg...@hotpads.com>
wrote:

> Yes, I have the log4j-web jar in my classpath, I'm in a servlet 3.0
> environment so I don't need any particular config, or did I miss something?
>
>
>
> On Sun, Jul 19, 2015 at 11:26 AM, Gary Gregory <ga...@gmail.com>
> wrote:
>
>> And you have your web app configured per
>> https://logging.apache.org/log4j/2.x/manual/webapp.html ?
>>
>> Gary
>>
>> On Sat, Jul 18, 2015 at 8:30 PM, Clément Guillaume <
>> cguillaume@hotpads.com>
>> wrote:
>>
>> > Yes, I trying to print the servletContext.servletContextName using the
>> > WebLookup (${web:servletContextName}). But it doesn't work for now.
>> >
>> > On Sat, Jul 18, 2015 at 8:26 PM, Gary Gregory <ga...@gmail.com>
>> > wrote:
>> >
>> > > So you are using servletContextName?
>> > >
>> > > Gary
>> > >
>> > > On Sat, Jul 18, 2015 at 8:19 PM, Clément Guillaume <
>> > cguillaume@hotpads.com
>> > > >
>> > > wrote:
>> > >
>> > > > Hi, thank you for your answers,
>> > > >
>> > > > My primary goal is to is to print the WebApplication name. I found
>> here
>> > > > <http://logging.apache.org/log4j/2.x/manual/webapp.html#
>> ContextParams>
>> > > > that
>> > > > by default the LoggerContext name is the WebApplication name.
>> > > >
>> > > > And I just found that the WebLookup
>> > > > <https://logging.apache.org/log4j/2.x/manual/lookups.html#WebLookup
>> >
>> > > > can achieve exactly
>> > > > what I want. But for now I can't make it
>> > > > works, WebLookup.getServletContext() is returning null, I'm
>> > investigating
>> > > > more (I'm using a 3.0 servlet).
>> > > >
>> > > > I'm also trying to make my custom Lookup, but it's currently not
>> found
>> > in
>> > > > the registered Lookups (even if the annotation processor find it and
>> > put
>> > > it
>> > > > into the Log4j2Plugins.dat file).
>> > > >
>> > > > On Fri, Jul 17, 2015 at 6:44 PM, Remko Popma <remko.popma@gmail.com
>> >
>> > > > wrote:
>> > > >
>> > > > > One way to achieve this would be to make a custom Lookup (
>> > > > > https://logging.apache.org/log4j/2.x/manual/extending.
>> html#Lookups)
>> > > and
>> > > > > include it in your PatternLayout's pattern.
>> > > > >
>> > > > > Sent from my iPhone
>> > > > >
>> > > > > > On 2015/07/18, at 9:39, Gary Gregory <ga...@gmail.com>
>> > wrote:
>> > > > > >
>> > > > > > Hm... I do not think so. Patches welcome of course. What are
>> your
>> > > > > > expectations for such a feature?
>> > > > > >
>> > > > > > Gary
>> > > > > >
>> > > > > > On Mon, Jul 13, 2015 at 8:24 PM, Clément Guillaume <
>> > > > > cguillaume@hotpads.com>
>> > > > > > wrote:
>> > > > > >
>> > > > > >> Is it possible to print the LoggerContext name in the output?
>> > > > > >>
>> > > > > >> Clément
>> > > > > >
>> > > > > >
>> > > > > >
>> > > > > > --
>> > > > > > E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> > > > > > Java Persistence with Hibernate, Second Edition
>> > > > > > <http://www.manning.com/bauer3/>
>> > > > > > JUnit in Action, Second Edition <http://www.manning.com/
>> tahchiev/>
>> > > > > > Spring Batch in Action <http://www.manning.com/templier/>
>> > > > > > Blog: http://garygregory.wordpress.com
>> > > > > > Home: http://garygregory.com/
>> > > > > > Tweet! http://twitter.com/GaryGregory
>> > > > >
>> > > >
>> > >
>> > >
>> > >
>> > > --
>> > > E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> > > Java Persistence with Hibernate, Second Edition
>> > > <http://www.manning.com/bauer3/>
>> > > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> > > Spring Batch in Action <http://www.manning.com/templier/>
>> > > Blog: http://garygregory.wordpress.com
>> > > Home: http://garygregory.com/
>> > > Tweet! http://twitter.com/GaryGregory
>> > >
>> >
>>
>>
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> Java Persistence with Hibernate, Second Edition
>> <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>>
>
>

Re: Print the LoggerContext name

Posted by Clément Guillaume <cg...@hotpads.com>.
Yes, I have the log4j-web jar in my classpath, I'm in a servlet 3.0
environment so I don't need any particular config, or did I miss something?



On Sun, Jul 19, 2015 at 11:26 AM, Gary Gregory <ga...@gmail.com>
wrote:

> And you have your web app configured per
> https://logging.apache.org/log4j/2.x/manual/webapp.html ?
>
> Gary
>
> On Sat, Jul 18, 2015 at 8:30 PM, Clément Guillaume <cguillaume@hotpads.com
> >
> wrote:
>
> > Yes, I trying to print the servletContext.servletContextName using the
> > WebLookup (${web:servletContextName}). But it doesn't work for now.
> >
> > On Sat, Jul 18, 2015 at 8:26 PM, Gary Gregory <ga...@gmail.com>
> > wrote:
> >
> > > So you are using servletContextName?
> > >
> > > Gary
> > >
> > > On Sat, Jul 18, 2015 at 8:19 PM, Clément Guillaume <
> > cguillaume@hotpads.com
> > > >
> > > wrote:
> > >
> > > > Hi, thank you for your answers,
> > > >
> > > > My primary goal is to is to print the WebApplication name. I found
> here
> > > > <
> http://logging.apache.org/log4j/2.x/manual/webapp.html#ContextParams>
> > > > that
> > > > by default the LoggerContext name is the WebApplication name.
> > > >
> > > > And I just found that the WebLookup
> > > > <https://logging.apache.org/log4j/2.x/manual/lookups.html#WebLookup>
> > > > can achieve exactly
> > > > what I want. But for now I can't make it
> > > > works, WebLookup.getServletContext() is returning null, I'm
> > investigating
> > > > more (I'm using a 3.0 servlet).
> > > >
> > > > I'm also trying to make my custom Lookup, but it's currently not
> found
> > in
> > > > the registered Lookups (even if the annotation processor find it and
> > put
> > > it
> > > > into the Log4j2Plugins.dat file).
> > > >
> > > > On Fri, Jul 17, 2015 at 6:44 PM, Remko Popma <re...@gmail.com>
> > > > wrote:
> > > >
> > > > > One way to achieve this would be to make a custom Lookup (
> > > > > https://logging.apache.org/log4j/2.x/manual/extending.html#Lookups
> )
> > > and
> > > > > include it in your PatternLayout's pattern.
> > > > >
> > > > > Sent from my iPhone
> > > > >
> > > > > > On 2015/07/18, at 9:39, Gary Gregory <ga...@gmail.com>
> > wrote:
> > > > > >
> > > > > > Hm... I do not think so. Patches welcome of course. What are your
> > > > > > expectations for such a feature?
> > > > > >
> > > > > > Gary
> > > > > >
> > > > > > On Mon, Jul 13, 2015 at 8:24 PM, Clément Guillaume <
> > > > > cguillaume@hotpads.com>
> > > > > > wrote:
> > > > > >
> > > > > >> Is it possible to print the LoggerContext name in the output?
> > > > > >>
> > > > > >> Clément
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > E-Mail: garydgregory@gmail.com | ggregory@apache.org
> > > > > > Java Persistence with Hibernate, Second Edition
> > > > > > <http://www.manning.com/bauer3/>
> > > > > > JUnit in Action, Second Edition <
> http://www.manning.com/tahchiev/>
> > > > > > Spring Batch in Action <http://www.manning.com/templier/>
> > > > > > Blog: http://garygregory.wordpress.com
> > > > > > Home: http://garygregory.com/
> > > > > > Tweet! http://twitter.com/GaryGregory
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > E-Mail: garydgregory@gmail.com | ggregory@apache.org
> > > Java Persistence with Hibernate, Second Edition
> > > <http://www.manning.com/bauer3/>
> > > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> > > Spring Batch in Action <http://www.manning.com/templier/>
> > > Blog: http://garygregory.wordpress.com
> > > Home: http://garygregory.com/
> > > Tweet! http://twitter.com/GaryGregory
> > >
> >
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>

Re: Print the LoggerContext name

Posted by Gary Gregory <ga...@gmail.com>.
And you have your web app configured per
https://logging.apache.org/log4j/2.x/manual/webapp.html ?

Gary

On Sat, Jul 18, 2015 at 8:30 PM, Clément Guillaume <cg...@hotpads.com>
wrote:

> Yes, I trying to print the servletContext.servletContextName using the
> WebLookup (${web:servletContextName}). But it doesn't work for now.
>
> On Sat, Jul 18, 2015 at 8:26 PM, Gary Gregory <ga...@gmail.com>
> wrote:
>
> > So you are using servletContextName?
> >
> > Gary
> >
> > On Sat, Jul 18, 2015 at 8:19 PM, Clément Guillaume <
> cguillaume@hotpads.com
> > >
> > wrote:
> >
> > > Hi, thank you for your answers,
> > >
> > > My primary goal is to is to print the WebApplication name. I found here
> > > <http://logging.apache.org/log4j/2.x/manual/webapp.html#ContextParams>
> > > that
> > > by default the LoggerContext name is the WebApplication name.
> > >
> > > And I just found that the WebLookup
> > > <https://logging.apache.org/log4j/2.x/manual/lookups.html#WebLookup>
> > > can achieve exactly
> > > what I want. But for now I can't make it
> > > works, WebLookup.getServletContext() is returning null, I'm
> investigating
> > > more (I'm using a 3.0 servlet).
> > >
> > > I'm also trying to make my custom Lookup, but it's currently not found
> in
> > > the registered Lookups (even if the annotation processor find it and
> put
> > it
> > > into the Log4j2Plugins.dat file).
> > >
> > > On Fri, Jul 17, 2015 at 6:44 PM, Remko Popma <re...@gmail.com>
> > > wrote:
> > >
> > > > One way to achieve this would be to make a custom Lookup (
> > > > https://logging.apache.org/log4j/2.x/manual/extending.html#Lookups)
> > and
> > > > include it in your PatternLayout's pattern.
> > > >
> > > > Sent from my iPhone
> > > >
> > > > > On 2015/07/18, at 9:39, Gary Gregory <ga...@gmail.com>
> wrote:
> > > > >
> > > > > Hm... I do not think so. Patches welcome of course. What are your
> > > > > expectations for such a feature?
> > > > >
> > > > > Gary
> > > > >
> > > > > On Mon, Jul 13, 2015 at 8:24 PM, Clément Guillaume <
> > > > cguillaume@hotpads.com>
> > > > > wrote:
> > > > >
> > > > >> Is it possible to print the LoggerContext name in the output?
> > > > >>
> > > > >> Clément
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > E-Mail: garydgregory@gmail.com | ggregory@apache.org
> > > > > Java Persistence with Hibernate, Second Edition
> > > > > <http://www.manning.com/bauer3/>
> > > > > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> > > > > Spring Batch in Action <http://www.manning.com/templier/>
> > > > > Blog: http://garygregory.wordpress.com
> > > > > Home: http://garygregory.com/
> > > > > Tweet! http://twitter.com/GaryGregory
> > > >
> > >
> >
> >
> >
> > --
> > E-Mail: garydgregory@gmail.com | ggregory@apache.org
> > Java Persistence with Hibernate, Second Edition
> > <http://www.manning.com/bauer3/>
> > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> > Spring Batch in Action <http://www.manning.com/templier/>
> > Blog: http://garygregory.wordpress.com
> > Home: http://garygregory.com/
> > Tweet! http://twitter.com/GaryGregory
> >
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: Print the LoggerContext name

Posted by Clément Guillaume <cg...@hotpads.com>.
Yes, I trying to print the servletContext.servletContextName using the
WebLookup (${web:servletContextName}). But it doesn't work for now.

On Sat, Jul 18, 2015 at 8:26 PM, Gary Gregory <ga...@gmail.com>
wrote:

> So you are using servletContextName?
>
> Gary
>
> On Sat, Jul 18, 2015 at 8:19 PM, Clément Guillaume <cguillaume@hotpads.com
> >
> wrote:
>
> > Hi, thank you for your answers,
> >
> > My primary goal is to is to print the WebApplication name. I found here
> > <http://logging.apache.org/log4j/2.x/manual/webapp.html#ContextParams>
> > that
> > by default the LoggerContext name is the WebApplication name.
> >
> > And I just found that the WebLookup
> > <https://logging.apache.org/log4j/2.x/manual/lookups.html#WebLookup>
> > can achieve exactly
> > what I want. But for now I can't make it
> > works, WebLookup.getServletContext() is returning null, I'm investigating
> > more (I'm using a 3.0 servlet).
> >
> > I'm also trying to make my custom Lookup, but it's currently not found in
> > the registered Lookups (even if the annotation processor find it and put
> it
> > into the Log4j2Plugins.dat file).
> >
> > On Fri, Jul 17, 2015 at 6:44 PM, Remko Popma <re...@gmail.com>
> > wrote:
> >
> > > One way to achieve this would be to make a custom Lookup (
> > > https://logging.apache.org/log4j/2.x/manual/extending.html#Lookups)
> and
> > > include it in your PatternLayout's pattern.
> > >
> > > Sent from my iPhone
> > >
> > > > On 2015/07/18, at 9:39, Gary Gregory <ga...@gmail.com> wrote:
> > > >
> > > > Hm... I do not think so. Patches welcome of course. What are your
> > > > expectations for such a feature?
> > > >
> > > > Gary
> > > >
> > > > On Mon, Jul 13, 2015 at 8:24 PM, Clément Guillaume <
> > > cguillaume@hotpads.com>
> > > > wrote:
> > > >
> > > >> Is it possible to print the LoggerContext name in the output?
> > > >>
> > > >> Clément
> > > >
> > > >
> > > >
> > > > --
> > > > E-Mail: garydgregory@gmail.com | ggregory@apache.org
> > > > Java Persistence with Hibernate, Second Edition
> > > > <http://www.manning.com/bauer3/>
> > > > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> > > > Spring Batch in Action <http://www.manning.com/templier/>
> > > > Blog: http://garygregory.wordpress.com
> > > > Home: http://garygregory.com/
> > > > Tweet! http://twitter.com/GaryGregory
> > >
> >
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>

Re: Print the LoggerContext name

Posted by Gary Gregory <ga...@gmail.com>.
So you are using servletContextName?

Gary

On Sat, Jul 18, 2015 at 8:19 PM, Clément Guillaume <cg...@hotpads.com>
wrote:

> Hi, thank you for your answers,
>
> My primary goal is to is to print the WebApplication name. I found here
> <http://logging.apache.org/log4j/2.x/manual/webapp.html#ContextParams>
> that
> by default the LoggerContext name is the WebApplication name.
>
> And I just found that the WebLookup
> <https://logging.apache.org/log4j/2.x/manual/lookups.html#WebLookup>
> can achieve exactly
> what I want. But for now I can't make it
> works, WebLookup.getServletContext() is returning null, I'm investigating
> more (I'm using a 3.0 servlet).
>
> I'm also trying to make my custom Lookup, but it's currently not found in
> the registered Lookups (even if the annotation processor find it and put it
> into the Log4j2Plugins.dat file).
>
> On Fri, Jul 17, 2015 at 6:44 PM, Remko Popma <re...@gmail.com>
> wrote:
>
> > One way to achieve this would be to make a custom Lookup (
> > https://logging.apache.org/log4j/2.x/manual/extending.html#Lookups) and
> > include it in your PatternLayout's pattern.
> >
> > Sent from my iPhone
> >
> > > On 2015/07/18, at 9:39, Gary Gregory <ga...@gmail.com> wrote:
> > >
> > > Hm... I do not think so. Patches welcome of course. What are your
> > > expectations for such a feature?
> > >
> > > Gary
> > >
> > > On Mon, Jul 13, 2015 at 8:24 PM, Clément Guillaume <
> > cguillaume@hotpads.com>
> > > wrote:
> > >
> > >> Is it possible to print the LoggerContext name in the output?
> > >>
> > >> Clément
> > >
> > >
> > >
> > > --
> > > E-Mail: garydgregory@gmail.com | ggregory@apache.org
> > > Java Persistence with Hibernate, Second Edition
> > > <http://www.manning.com/bauer3/>
> > > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> > > Spring Batch in Action <http://www.manning.com/templier/>
> > > Blog: http://garygregory.wordpress.com
> > > Home: http://garygregory.com/
> > > Tweet! http://twitter.com/GaryGregory
> >
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: Print the LoggerContext name

Posted by Clément Guillaume <cg...@hotpads.com>.
Hi, thank you for your answers,

My primary goal is to is to print the WebApplication name. I found here
<http://logging.apache.org/log4j/2.x/manual/webapp.html#ContextParams> that
by default the LoggerContext name is the WebApplication name.

And I just found that the WebLookup
<https://logging.apache.org/log4j/2.x/manual/lookups.html#WebLookup>
can achieve exactly
what I want. But for now I can't make it
works, WebLookup.getServletContext() is returning null, I'm investigating
more (I'm using a 3.0 servlet).

I'm also trying to make my custom Lookup, but it's currently not found in
the registered Lookups (even if the annotation processor find it and put it
into the Log4j2Plugins.dat file).

On Fri, Jul 17, 2015 at 6:44 PM, Remko Popma <re...@gmail.com> wrote:

> One way to achieve this would be to make a custom Lookup (
> https://logging.apache.org/log4j/2.x/manual/extending.html#Lookups) and
> include it in your PatternLayout's pattern.
>
> Sent from my iPhone
>
> > On 2015/07/18, at 9:39, Gary Gregory <ga...@gmail.com> wrote:
> >
> > Hm... I do not think so. Patches welcome of course. What are your
> > expectations for such a feature?
> >
> > Gary
> >
> > On Mon, Jul 13, 2015 at 8:24 PM, Clément Guillaume <
> cguillaume@hotpads.com>
> > wrote:
> >
> >> Is it possible to print the LoggerContext name in the output?
> >>
> >> Clément
> >
> >
> >
> > --
> > E-Mail: garydgregory@gmail.com | ggregory@apache.org
> > Java Persistence with Hibernate, Second Edition
> > <http://www.manning.com/bauer3/>
> > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> > Spring Batch in Action <http://www.manning.com/templier/>
> > Blog: http://garygregory.wordpress.com
> > Home: http://garygregory.com/
> > Tweet! http://twitter.com/GaryGregory
>

Re: Print the LoggerContext name

Posted by Remko Popma <re...@gmail.com>.
One way to achieve this would be to make a custom Lookup (https://logging.apache.org/log4j/2.x/manual/extending.html#Lookups) and include it in your PatternLayout's pattern. 

Sent from my iPhone

> On 2015/07/18, at 9:39, Gary Gregory <ga...@gmail.com> wrote:
> 
> Hm... I do not think so. Patches welcome of course. What are your
> expectations for such a feature?
> 
> Gary
> 
> On Mon, Jul 13, 2015 at 8:24 PM, Clément Guillaume <cg...@hotpads.com>
> wrote:
> 
>> Is it possible to print the LoggerContext name in the output?
>> 
>> Clément
> 
> 
> 
> -- 
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory

Re: Print the LoggerContext name

Posted by Gary Gregory <ga...@gmail.com>.
Hm... I do not think so. Patches welcome of course. What are your
expectations for such a feature?

Gary

On Mon, Jul 13, 2015 at 8:24 PM, Clément Guillaume <cg...@hotpads.com>
wrote:

> Is it possible to print the LoggerContext name in the output?
>
> Clément
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory