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 Benjamin Jaton <be...@gmail.com> on 2015/06/06 01:33:49 UTC

how to reinitialize log4j2 configuration?

Hello

After an initial configuration of log4j2 with:

    Configurator.initialize(null, configLocation);

I would like to reinitialize it with a different URL

    Configurator.initialize(null, configLocation2);

The problem is that the second call is ignored. I believe that once the
LoggerContext is STARTED it will ignore reconfigurations.

Is there a way to do this?

Thanks!
Ben

Re: how to reinitialize log4j2 configuration?

Posted by Remko Popma <re...@gmail.com>.
I added this (and two more questions) to the FAQ.
Please verify if I got the LogManager.getContext(TRUE/FALSE) parameter
right...

On Wed, Jun 17, 2015 at 7:49 AM, Gary Gregory <ga...@gmail.com>
wrote:

> Is this an item for our FAQ or manual? It would be nice to eventually be
> able to answer these kinds of questions with links to the site. :-)
>
> G
>
> On Tue, Jun 16, 2015 at 2:44 PM, Benjamin Jaton <be...@gmail.com>
> wrote:
>
> > This works great thanks!
> >
> > On Fri, Jun 5, 2015 at 9:22 PM, Ralph Goers <ra...@dslextreme.com>
> > wrote:
> >
> > > Once you have a LoggerContext you can call
> > > context.setConfigLocation(configLocation) where configLocation is a
> URI.
> > > That will force a reconfiguration.
> > >
> > > Ralph
> > >
> > > > On Jun 5, 2015, at 4:33 PM, Benjamin Jaton <benjamin.jaton@gmail.com
> >
> > > wrote:
> > > >
> > > > Hello
> > > >
> > > > After an initial configuration of log4j2 with:
> > > >
> > > >    Configurator.initialize(null, configLocation);
> > > >
> > > > I would like to reinitialize it with a different URL
> > > >
> > > >    Configurator.initialize(null, configLocation2);
> > > >
> > > > The problem is that the second call is ignored. I believe that once
> the
> > > > LoggerContext is STARTED it will ignore reconfigurations.
> > > >
> > > > Is there a way to do this?
> > > >
> > > > Thanks!
> > > > Ben
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > > For additional commands, e-mail: log4j-user-help@logging.apache.org
> > >
> > >
> >
>
>
>
> --
> 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: how to reinitialize log4j2 configuration?

Posted by Gary Gregory <ga...@gmail.com>.
Is this an item for our FAQ or manual? It would be nice to eventually be
able to answer these kinds of questions with links to the site. :-)

G

On Tue, Jun 16, 2015 at 2:44 PM, Benjamin Jaton <be...@gmail.com>
wrote:

> This works great thanks!
>
> On Fri, Jun 5, 2015 at 9:22 PM, Ralph Goers <ra...@dslextreme.com>
> wrote:
>
> > Once you have a LoggerContext you can call
> > context.setConfigLocation(configLocation) where configLocation is a URI.
> > That will force a reconfiguration.
> >
> > Ralph
> >
> > > On Jun 5, 2015, at 4:33 PM, Benjamin Jaton <be...@gmail.com>
> > wrote:
> > >
> > > Hello
> > >
> > > After an initial configuration of log4j2 with:
> > >
> > >    Configurator.initialize(null, configLocation);
> > >
> > > I would like to reinitialize it with a different URL
> > >
> > >    Configurator.initialize(null, configLocation2);
> > >
> > > The problem is that the second call is ignored. I believe that once the
> > > LoggerContext is STARTED it will ignore reconfigurations.
> > >
> > > Is there a way to do this?
> > >
> > > Thanks!
> > > Ben
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> >
>



-- 
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: how to reinitialize log4j2 configuration?

Posted by Benjamin Jaton <be...@gmail.com>.
This works great thanks!

On Fri, Jun 5, 2015 at 9:22 PM, Ralph Goers <ra...@dslextreme.com>
wrote:

> Once you have a LoggerContext you can call
> context.setConfigLocation(configLocation) where configLocation is a URI.
> That will force a reconfiguration.
>
> Ralph
>
> > On Jun 5, 2015, at 4:33 PM, Benjamin Jaton <be...@gmail.com>
> wrote:
> >
> > Hello
> >
> > After an initial configuration of log4j2 with:
> >
> >    Configurator.initialize(null, configLocation);
> >
> > I would like to reinitialize it with a different URL
> >
> >    Configurator.initialize(null, configLocation2);
> >
> > The problem is that the second call is ignored. I believe that once the
> > LoggerContext is STARTED it will ignore reconfigurations.
> >
> > Is there a way to do this?
> >
> > Thanks!
> > Ben
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Re: how to reinitialize log4j2 configuration?

Posted by Ralph Goers <ra...@dslextreme.com>.
Once you have a LoggerContext you can call context.setConfigLocation(configLocation) where configLocation is a URI.  That will force a reconfiguration.

Ralph

> On Jun 5, 2015, at 4:33 PM, Benjamin Jaton <be...@gmail.com> wrote:
> 
> Hello
> 
> After an initial configuration of log4j2 with:
> 
>    Configurator.initialize(null, configLocation);
> 
> I would like to reinitialize it with a different URL
> 
>    Configurator.initialize(null, configLocation2);
> 
> The problem is that the second call is ignored. I believe that once the
> LoggerContext is STARTED it will ignore reconfigurations.
> 
> Is there a way to do this?
> 
> Thanks!
> Ben



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