logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcel Stör <mar...@frightanic.com>
Subject Switching log levels at runtime with log4j2
Date Mon, 28 Nov 2016 20:28:11 GMT
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


Mime
View raw message