Re: Change log level on the fly?

2015-11-09 Thread Matt Sicker
Oh, good catch, never used the API like that outside of unit tests. On 9 November 2015 at 23:21, Ralph Goers wrote: > Matt, the advice below won’t work properly. The LoggerConfig must be > modified, not the Logger. Then updateLoggers must be called (which will > update the logger’s level). > > R

Re: Change log level on the fly?

2015-11-09 Thread Ralph Goers
Matt, the advice below won’t work properly. The LoggerConfig must be modified, not the Logger. Then updateLoggers must be called (which will update the logger’s level). Ralph > On Nov 9, 2015, at 9:07 PM, Matt Sicker wrote: > > You can find the Logger from LogManager, cast to > org.apache.log

Re: Change log level on the fly?

2015-11-09 Thread Ralph Goers
We have unit tests that do this. Basically you need to do: final LoggerContext ctx = (LoggerContext) LogManager.getContext(false); final Configuration config = ctx.getConfiguration(); Map loggers = config.getLoggers(); for (Map.Entry logger : loggers.entrySet()) { logger.setLevel(Level.DEBUG)

Re: Change log level on the fly?

2015-11-09 Thread Matt Sicker
And by JMX, I meant the MBean class (not jConsole): http://logging.apache.org/log4j/2.x/log4j-core/apidocs/org/apache/logging/log4j/core/jmx/LoggerConfigAdminMBean.html On 9 November 2015 at 22:07, Matt Sicker wrote: > You can find the Logger from LogManager, cast to > org.apache.logging.log4j.c

Re: Change log level on the fly?

2015-11-09 Thread Matt Sicker
You can find the Logger from LogManager, cast to org.apache.logging.log4j.core.Logger, and use setLevel, though I bet there's a better way to do this via configuration files. You can reload the configuration file and modify that from the user, but that might be overkill here. On 9 November 2015 at

RE: Change log level on the fly?

2015-11-09 Thread John Lussmyer
Looking at https://logging.apache.org/log4j/2.0/manual/jmx.html Doesn't seem like the solution. Asking the user to bring up jconsole seems rather excessive. I just want to provide 3 radio buttons in my configuration. Logging Normal, Medium, Full. -Original Message- From: Matt Sicker [mai

Re: Change log level on the fly?

2015-11-09 Thread Matt Sicker
Loggers can be reconfigured through JMX. On 9 November 2015 at 19:53, John Lussmyer wrote: > I'm hoping there is an easy to to just change the root level of my logger > configuration on the fly. > I want to be able to provide a configuration option to my users to turn up > the logging level. > I

Change log level on the fly?

2015-11-09 Thread John Lussmyer
I'm hoping there is an easy to to just change the root level of my logger configuration on the fly. I want to be able to provide a configuration option to my users to turn up the logging level. I don't want to reconfigure everything, just change the level. Is there any easy way to do that? Or d

Re: Log4j2 - HTML emails pattern

2015-11-09 Thread Gary Gregory
Ben, Is there a way the current HTML layout could be customized to be better suited to your use-case? Gary On Mon, Nov 9, 2015 at 11:09 AM, Benjamin Jaton wrote: > Thanks the feedback. > I found that the easiest way to achieve this was to have the PatternLayout > class support to set the conte

Re: Log4j2 - HTML emails pattern

2015-11-09 Thread Benjamin Jaton
Thanks the feedback. I found that the easiest way to achieve this was to have the PatternLayout class support to set the contentType to "text/html". Then one can write HTML directly in the pattern. Thanks again, Ben On Mon, Nov 9, 2015 at 6:51 AM, Remko Popma wrote: > Ben, > > The built-in HTML

Re: Log4j2 - HTML emails pattern

2015-11-09 Thread Remko Popma
Ben, The built-in HTML layout (https://logging.apache.org/log4j/2.x/log4j-core/xref/org/apache/logging/log4j/core/layout/HtmlLayout.html) does not support much customization. It sounds like you may want to create a custom layout and specify that layout with the SMTP appender. This manual p