Re: Log4j2 replacement of PropertyConfigurator APIs configureAndWatch and configure

2023-03-22 Thread Viraj Jasani
Sounds good, thanks! > Looking at what that code is doing it is just enabling logging to a file at a level for some time period. In addition to that, it’s also updating thresholds of all the appenders (and reseting them to previous level by a job). That's the part I was bit worried about as to wh

Re: Log4j2 replacement of PropertyConfigurator APIs configureAndWatch and configure

2023-03-21 Thread Ralph Goers
Yes, it is doable. That said, there are almost always better ways to implement whatever your “real” requirement is. Looking at what that code is doing it is just enabling logging to a file at a level for some time period. Instead, you can just create the Appender in your configuration and conf

Re: Log4j2 replacement of PropertyConfigurator APIs configureAndWatch and configure

2023-03-21 Thread Viraj Jasani
Thanks a lot, Ralph! Let me ask one more question. For any further questions, I would create a new mail thread. We also have a utility in hadoop that tries to add FileAppender at runtime, and also change the threshold of all appenders from root level. Is this doable with log4j2? I could not find A

Re: Log4j2 replacement of PropertyConfigurator APIs configureAndWatch and configure

2023-03-21 Thread Ralph Goers
Actually, Configurator.reconfigure() will cause the existing configuration (file or uri) to be reloaded. You would use it with the uri or configuration parameter if you want to load a new configuration. Ralph > On Mar 21, 2023, at 5:48 PM, Viraj Jasani wrote: > > I believe we can use "Configu

Re: Log4j2 replacement of PropertyConfigurator APIs configureAndWatch and configure

2023-03-21 Thread Viraj Jasani
I believe we can use "Configurator.reconfigure(uri)", however just wanted to make sure if this is the only right way (stable API). On Tue, Mar 21, 2023 at 4:57 PM Viraj Jasani wrote: > Just a follow up on this, do we have replacement for > "LogManager.resetConfiguration" in log4j2? > > > On Sat

Re: Log4j2 replacement of PropertyConfigurator APIs configureAndWatch and configure

2023-03-21 Thread Viraj Jasani
Just a follow up on this, do we have replacement for "LogManager.resetConfiguration" in log4j2? On Sat, Mar 18, 2023 at 11:27 AM Viraj Jasani wrote: > Ah looks like monitorinterval is supported as per the doc[1]: > Properties configuration files support the advertiser, monitorInterval, > name,

Re: Log4j2 replacement of PropertyConfigurator APIs configureAndWatch and configure

2023-03-18 Thread Ralph Goers
Yes, everything is supported in the Properties format, but the syntax is confusing to almost everyone. Ralph > On Mar 18, 2023, at 11:27 AM, Viraj Jasani wrote: > > Ah looks like monitorinterval is supported as per the doc[1]: > Properties configuration files support the advertiser, monitorInt

Re: Log4j2 replacement of PropertyConfigurator APIs configureAndWatch and configure

2023-03-18 Thread Viraj Jasani
Ah looks like monitorinterval is supported as per the doc[1]: Properties configuration files support the advertiser, monitorInterval, name, packages, shutdownHook, shutdownTimeout, status, verbose, and dest attributes. 1. https://logging.apache.org/log4j/2.x/manual/configuration.html#Configuration

Re: Log4j2 replacement of PropertyConfigurator APIs configureAndWatch and configure

2023-03-18 Thread Viraj Jasani
Thanks Ralph for the recommendations! > First, I strongly recommend you switch from properties to either XML, Yaml, or JSON. The reason why we would still like to stick to properties (at least for now during the migration) is that LOG4J2-3341 allows setting level and appender at once in the prope

Re: Log4j2 replacement of PropertyConfigurator APIs configureAndWatch and configure

2023-03-18 Thread Ralph Goers
First, I strongly recommend you switch from properties to either XML, Yaml, or JSON. To prgormatically configure Log4j2 do Configurator.initialize(“ConfigName”, “log4j2.xml”); Note that there are several variations of the initialize method. If the configuration contains a monitorInterval th