Exemplo n.º 1
0
    // Private method to reset an invidual target logger.
    private void resetLogger(String name) {
	Logger logger = getLogger(name);
	if (logger == null) {
	    return;
	}
	// Close all the Logger's handlers.
	Handler[] targets = logger.getHandlers();
	for (int i = 0; i < targets.length; i++) {
	    Handler h = targets[i];
	    logger.removeHandler(h);
	    try {
	        h.close();
	    } catch (Exception ex) {
		// Problems closing a handler?  Keep going...
	    }
	}
	if (name != null && name.equals("")) {
	    // This is the root logger.
	    logger.setLevel(defaultLevel);
	} else {
	    logger.setLevel(null);
	}
    }
Exemplo n.º 2
0
    // Private method to set a level on a logger.
    // If necessary, we raise privilege before doing the call.
    private static void doSetLevel(final Logger logger, final Level level) {
	SecurityManager sm = System.getSecurityManager();
	if (sm == null) {
	    // There is no security manager, so things are easy.
	    logger.setLevel(level);
	    return;
	} 
	// There is a security manager.  Raise privilege before
	// calling setLevel.
	AccessController.doPrivileged(new PrivilegedAction() {
	    public Object run() {
	        logger.setLevel(level);
		return null;
	    }});
    }
Exemplo n.º 3
0
    // Private method to be called when the configuration has
    // changed to apply any level settings to any pre-existing loggers.
    synchronized private void setLevelsOnExistingLoggers() {
	Enumeration enum = props.propertyNames();
	while (enum.hasMoreElements()) {
	    String key = (String)enum.nextElement();
	    if (!key.endsWith(".level")) {
		// Not a level definition.
		continue;
	    }
	    int ix = key.length() - 6;
	    String name = key.substring(0, ix);
	    Level level = getLevelProperty(key, null);
	    if (level == null) {
		System.err.println("Bad level value for property: " + key);
		continue;
	    }
	    Logger l = getLogger(name);
	    if (l == null) {
		continue;
	    }
	    l.setLevel(level);
	}
    }