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 John Lussmyer <Co...@CasaDelGato.com> on 2018/08/14 15:35:26 UTC
Changing xml config file after startup
Our (old) code that uses log4j does the following in order to swap xml configurations after app initialization.
final org.apache.logging.log4j.core.LoggerContext ctx = (org.apache.logging.log4j.core.LoggerContext) LogManager.getContext(false);
ctx.reconfigure();
ctx.updateLoggers();
Is there a new supported way of doing the same thing? (The above really seems kind of hacky.)
Re: Changing xml config file after startup
Posted by John Lussmyer <Co...@CasaDelGato.com>.
Ok, LOG4J2-2406 created.
On Tue Aug 14 09:22:39 PDT 2018 ralph.goers@dslextreme.com said:
>You don?t need to call ctx.updateLoggers(). That is done already inside the ctx.reconfigure().
>
>In short, you could shorten that to one line
>
>((org.apache.logging.log4j.core.LoggerContext) LogManager.getContext(false)).reconfigure();
>
>That could certainly be added to the Configurator class as
>
>Configurator.reconfigure();
>
>If that is what you want please create a Jira issue and summarize this there.
>
>Ralph
>
>> On Aug 14, 2018, at 9:14 AM, Ralph Goers <ra...@dslextreme.com> wrote:
>>
>> You are simply trying to refresh the configuration from the same location?
>>
>> Ralph
>>
>>> On Aug 14, 2018, at 8:35 AM, John Lussmyer <Co...@CasaDelGato.com> wrote:
>>>
>>> Our (old) code that uses log4j does the following in order to swap xml configurations after app initialization.
>>>
>>> final org.apache.logging.log4j.core.LoggerContext ctx = (org.apache.logging.log4j.core.LoggerContext) LogManager.getContext(false);
>>> ctx.reconfigure();
>>> ctx.updateLoggers();
>>>
>>> Is there a new supported way of doing the same thing? (The above really seems kind of hacky.)
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-user-help@logging.apache.org
--
Worlds only All Electric F-250 truck! http://john.casadelgato.com/Electric-Vehicles/1995-Ford-F-250
Re: Changing xml config file after startup
Posted by Ralph Goers <ra...@dslextreme.com>.
You don’t need to call ctx.updateLoggers(). That is done already inside the ctx.reconfigure().
In short, you could shorten that to one line
((org.apache.logging.log4j.core.LoggerContext) LogManager.getContext(false)).reconfigure();
That could certainly be added to the Configurator class as
Configurator.reconfigure();
If that is what you want please create a Jira issue and summarize this there.
Ralph
> On Aug 14, 2018, at 9:14 AM, Ralph Goers <ra...@dslextreme.com> wrote:
>
> You are simply trying to refresh the configuration from the same location?
>
> Ralph
>
>> On Aug 14, 2018, at 8:35 AM, John Lussmyer <Co...@CasaDelGato.com> wrote:
>>
>> Our (old) code that uses log4j does the following in order to swap xml configurations after app initialization.
>>
>> final org.apache.logging.log4j.core.LoggerContext ctx = (org.apache.logging.log4j.core.LoggerContext) LogManager.getContext(false);
>> ctx.reconfigure();
>> ctx.updateLoggers();
>>
>> Is there a new supported way of doing the same thing? (The above really seems kind of hacky.)
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: Changing xml config file after startup
Posted by John Lussmyer <Co...@CasaDelGato.com>.
Location can change as well.
When app first starts up, it'll end up using the log4j.xml that is in the .jar file.
We then create (if needed) a AppName.log4j.xml file in our logs directory, and switch log4j to use that one.
On Tue Aug 14 09:14:33 PDT 2018 ralph.goers@dslextreme.com said:
>You are simply trying to refresh the configuration from the same location?
>
>Ralph
>
>> On Aug 14, 2018, at 8:35 AM, John Lussmyer <Co...@CasaDelGato.com> wrote:
>>
>> Our (old) code that uses log4j does the following in order to swap xml configurations after app initialization.
>>
>> final org.apache.logging.log4j.core.LoggerContext ctx = (org.apache.logging.log4j.core.LoggerContext) LogManager.getContext(false);
>> ctx.reconfigure();
>> ctx.updateLoggers();
>>
>> Is there a new supported way of doing the same thing? (The above really seems kind of hacky.)
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-user-help@logging.apache.org
--
Try my Sensible Email package! https://sourceforge.net/projects/sensibleemail/
Re: Changing xml config file after startup
Posted by Ralph Goers <ra...@dslextreme.com>.
You are simply trying to refresh the configuration from the same location?
Ralph
> On Aug 14, 2018, at 8:35 AM, John Lussmyer <Co...@CasaDelGato.com> wrote:
>
> Our (old) code that uses log4j does the following in order to swap xml configurations after app initialization.
>
> final org.apache.logging.log4j.core.LoggerContext ctx = (org.apache.logging.log4j.core.LoggerContext) LogManager.getContext(false);
> ctx.reconfigure();
> ctx.updateLoggers();
>
> Is there a new supported way of doing the same thing? (The above really seems kind of hacky.)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org