logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: Switching log levels at runtime with log4j2
Date Mon, 28 Nov 2016 20:58:49 GMT
Does this help:



On Mon, Nov 28, 2016 at 12:28 PM, Marcel Stör <marcel@frightanic.com> wrote:

> For years we've been shipping our web applications with a simple and
> ugly but tremendously effective Servlet to switch log4j log levels at
> runtime[1]. In fact, it's been so effective on countless occasions
> (read: debugging sessions in production environments) that we never
> bothered looking into alternatives.
> Until we started introducing log4j2.
> The old Servlet uses LogManager.getRootLogger() and
> LogManager.getCurrentLoggers() to build the list of loggers and
> Logger.getLogger(String).setLevel(Level.toLevel(String)) to update them.
> I learned that with log4j2 you don't actually manipulate loggers but
> their respective configuration[2]. Based on what I saw I assume I could
> re-write our Servlet to work with log2j2. Please correct me if my
> assumptions are wrong.
> However, it may very well be that I missed some of the new features
> which would make our Servlet altogether obsolete. DynamicThresholdFilter
> for example is nice but solves a related but slightly different problem.
> Is there a log4j2 feature that could replace our Servlet?
> [1] http://imgur.com/a/JHaOY
> [2] http://stackoverflow.com/q/17511763/131929
> --
> Marcel Stör, http://frightanic.com
> Couchsurfing: http://www.couchsurfing.com/people/marcelstoer
> O< ascii ribbon campaign - stop html mail - http://j.mp/1OThh9L

E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition

JUnit in Action, Second Edition

Spring Batch in Action
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message