Re: Log4j2: Programmatically setting log4j2 log level

2013-07-22 Thread Ralph Goers
Well, you can actually do that. It is just not my number one recommendation :-) I'm pretty sure I have answered how to do that a few times. It just needs to be documented. The actual code to do this is LoggerContext ctx = (LoggerContext) LogManager.getContext(false); Configurat

Re: Log4j2: Programmatically setting log4j2 log level

2013-07-22 Thread Nicholas Williams
I can live with having to use the Core directly to change logger levels, as opposed to using the API. But your solution of cloning, changing, and replacing the configuration seems extremely heavy and excessive for merely changing the level for a single logger. There are a lot of other things that h

Re: Log4j2: Programmatically setting log4j2 log level

2013-07-22 Thread Ralph Goers
I guess I have to disagree. With Logback it is more explicit since SLF4J is its API. The more of this stuff that gets added to the API the more difficult it is going to be to keep the API separate from the implementation. My view is that the API is primarily for applications that want to use

Re: Log4j2: Programmatically setting log4j2 log level

2013-07-22 Thread Ralph Goers
The way I recommend would be to clone the active Configuration, make the desired modifications to it and then replace the Configuration. That will take care of updating all the loggers and won't have threading issues. I noticed that the JMX stuff doesn't do that. Ralph On Jul 22, 2013, at 1

Re: Log4j2: Programmatically setting log4j2 log level

2013-07-22 Thread Gary Gregory
This seems like an "obvious" feature and should be part of the public API/feature set (IMO). Gary On Mon, Jul 22, 2013 at 3:08 PM, Nick Williams < nicho...@nicholaswilliams.net> wrote: > We do the _exact same thing_ in our apps that use Log4j 1. Being able to > do this is crucial to us. Being a

Re: Log4j2: Programmatically setting log4j2 log level

2013-07-22 Thread Nick Williams
We do the _exact same thing_ in our apps that use Log4j 1. Being able to do this is crucial to us. Being able to do this using the API is ideal and obviously preferred so that the Core can be a runtime dependency, but as long as we can do it one way or another we're ok. Nick On Jul 22, 2013, a

Re: Log4j2: Programmatically setting log4j2 log level

2013-07-22 Thread Gary Gregory
Here is a user story I have at work all the time, which I'd like to be able to do in Log4J 2 when we eventually migrate to it. Our server starts. A couple of days later, something goes wrong. Our user contacts us and we tell them to use our admin console to enable debugging for X and Y. This cause

Re: Log4j2: Programmatically setting log4j2 log level

2013-07-22 Thread Ralph Goers
Can you explain what it is you are really trying to do? Rather than just answer specific questions I am wondering if there isn't a better way to do what you want. Ralph On Jul 22, 2013, at 7:14 AM, SMITH, CURTIS wrote: > From a thread back in May: > > My question to the below snips of the t

Log4j2: Programmatically setting log4j2 log level

2013-07-22 Thread SMITH, CURTIS
>From a thread back in May: My question to the below snips of the thread are; My app has many Catagories (using 1.x terminology). To setLevel in 1.x I had to getCurrentCatagories() and iterate over the list setting level. In 2.x, does the code below set all Appenders regardless of what Level t