logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matthew Kemp" <mattk...@gmail.com>
Subject Re: changing logger log levels while application is running
Date Wed, 12 Dec 2007 22:39:46 GMT
To expand on Orko's comment, the code to do this would look something like:

// to get a logger level as a string
public String getLoggerLevel(String loggerName) {
  return Logger.getLogger(loggerName).getLevel().toString();

// to set a logger level as a string
public void setLoggerLevel(String loggerName, String levelName) {
  Level level = Level.tolevel(levelName);

On Dec 12, 2007 4:26 PM, orko <orko_147@yahoo.com> wrote:

> There is a method called setLevel in Category. You may want to getLevel of
> the logger and then set it up to a new log level.
> David Killeffer <rayden7@gmail.com> wrote: I'm trying to write a servlet
> that will let me change the log level (and
> thereby optionally turn the logger on/off) of a logger that is running in
> my
> application code somewhere else.  Currently I have logging running in my
> application fine, and I have been able to get information on the logger
> and
> appenders that are running, but changing the level of the logger doesn't
> stop the application code from continuing to log.
> Is it possible to change the log level of a logger in memory
> (programmatically) by way of a servlet that would then change logging for
> my
> application code?
> - David

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