How to get loggers in java.util.logging so i can change their log level at runtime? -


i using java.util.logging in different classes. log level's default value info. example in 1 class class1 setup way:

import java.util.logging.handler; import java.util.logging.level; import java.util.logging.logger;  public class class1 {    private static final logger logger = logger.getlogger(class1.class.getname());    static {        logger.setlevel(level.info);        (handler handler : logger.gethandlers()) {            handler.setlevel(level.info);        }               }    ... } 

the above same way setup in different classes.

now log level changed @ runtime. example suppose changed finest @ runtime. in case want loggers have been created far , change log level finest. how can that? thinking creating class logrepository has java.util.list , whenever logger created, add java.util.list of logrepository. think there may better way.

i believe matter of setting level of parent logger of instances inherit from.

logger.getlogger("").setlevel(level.finest); 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -