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 alwin james <ja...@gmail.com> on 2019/04/02 23:10:22 UTC

How to change the log4j2 log level of a running application without restarting?

Hi Team,

How can we change the log level of a running application without
restarting the program?

It will be really helpful if someone can point me in the right direction.

Any Java examples or documentation?

I used to achieve this using 'DOMConfigurator' in log4j.

Regards,

Re: How to change the log4j2 log level of a running application without restarting?

Posted by Gary Gregory <ga...@gmail.com>.
HiHi,

Take a look at the Configurator class.

Gary

On Tue, Apr 2, 2019, 19:19 alwin james <ja...@gmail.com> wrote:

> Hi Team,
>
> How can we change the log level of a running application without
> restarting the program?
>
> It will be really helpful if someone can point me in the right direction.
>
> Any Java examples or documentation?
>
> I used to achieve this using 'DOMConfigurator' in log4j.
>
> Regards,
>

Re: How to change the log4j2 log level of a running application without restarting?

Posted by Remko Popma <re...@gmail.com>.

> On Apr 3, 2019, at 9:34, Alex O'Ree <al...@apache.org> wrote:
> 
> Isn't there a JMX/mbean based solution?
Yes there is. 
This page has more detail: https://logging.apache.org/log4j/2.x/manual/jmx.html

I remember there is an MBean API for changing the log level. 


> 
> On Tue, Apr 2, 2019 at 8:29 PM Ralph Goers <ra...@dslextreme.com>
> wrote:
> 
>> There are several ways. If you are using Spring Boot you can use the REST
>> API they provide. If you are using a configuration file just add
>> monitorInterval=n where n is the number of seconds to poll for changes. The
>> configuration will automatically reload if you do that. Finally, as Gary
>> noted you can programmatically do that using the Configurator class.
>> 
>> Ralph
>> 
>>> On Apr 2, 2019, at 4:10 PM, alwin james <ja...@gmail.com> wrote:
>>> 
>>> Hi Team,
>>> 
>>> How can we change the log level of a running application without
>>> restarting the program?
>>> 
>>> It will be really helpful if someone can point me in the right direction.
>>> 
>>> Any Java examples or documentation?
>>> 
>>> I used to achieve this using 'DOMConfigurator' in log4j.
>>> 
>>> Regards,
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>> 
>> 

Re: How to change the log4j2 log level of a running application without restarting?

Posted by Alex O'Ree <al...@apache.org>.
Isn't there a JMX/mbean based solution?

On Tue, Apr 2, 2019 at 8:29 PM Ralph Goers <ra...@dslextreme.com>
wrote:

> There are several ways. If you are using Spring Boot you can use the REST
> API they provide. If you are using a configuration file just add
> monitorInterval=n where n is the number of seconds to poll for changes. The
> configuration will automatically reload if you do that. Finally, as Gary
> noted you can programmatically do that using the Configurator class.
>
> Ralph
>
> > On Apr 2, 2019, at 4:10 PM, alwin james <ja...@gmail.com> wrote:
> >
> > Hi Team,
> >
> > How can we change the log level of a running application without
> > restarting the program?
> >
> > It will be really helpful if someone can point me in the right direction.
> >
> > Any Java examples or documentation?
> >
> > I used to achieve this using 'DOMConfigurator' in log4j.
> >
> > Regards,
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Re: How to change the log4j2 log level of a running application without restarting?

Posted by alwin james <ja...@gmail.com>.
Thank you Ralph and Gary for quick response.

I was testing using the 'monitorInterval' in intellij. I was testing by
changing log4j2.xml file in 'resources' folder.
I completely forgot the fact that the files get copied to 'out' from the
source folder when intellij starts running the application.

Regards,
Alwin

On Tue, Apr 2, 2019, 5:29 PM Ralph Goers <ra...@dslextreme.com> wrote:

> There are several ways. If you are using Spring Boot you can use the REST
> API they provide. If you are using a configuration file just add
> monitorInterval=n where n is the number of seconds to poll for changes. The
> configuration will automatically reload if you do that. Finally, as Gary
> noted you can programmatically do that using the Configurator class.
>
> Ralph
>
> > On Apr 2, 2019, at 4:10 PM, alwin james <ja...@gmail.com> wrote:
> >
> > Hi Team,
> >
> > How can we change the log level of a running application without
> > restarting the program?
> >
> > It will be really helpful if someone can point me in the right direction.
> >
> > Any Java examples or documentation?
> >
> > I used to achieve this using 'DOMConfigurator' in log4j.
> >
> > Regards,
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Re: How to change the log4j2 log level of a running application without restarting?

Posted by Ralph Goers <ra...@dslextreme.com>.
There are several ways. If you are using Spring Boot you can use the REST API they provide. If you are using a configuration file just add monitorInterval=n where n is the number of seconds to poll for changes. The configuration will automatically reload if you do that. Finally, as Gary noted you can programmatically do that using the Configurator class.

Ralph

> On Apr 2, 2019, at 4:10 PM, alwin james <ja...@gmail.com> wrote:
> 
> Hi Team,
> 
> How can we change the log level of a running application without
> restarting the program?
> 
> It will be really helpful if someone can point me in the right direction.
> 
> Any Java examples or documentation?
> 
> I used to achieve this using 'DOMConfigurator' in log4j.
> 
> Regards,



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