⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logger.java

📁 JAVA基本类源代码,大家可以学习学习!
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
     * @param   param1    Parameter to the log message.     * @throws  MissingResourceException if no suitable ResourceBundle can     *		be found.     */    public void logrb(Level level, String sourceClass, String sourceMethod,				String bundleName, String msg, Object param1) {	if (level.intValue() < levelValue || levelValue == offValue) {	    return;	}	LogRecord lr = new LogRecord(level, msg);	lr.setSourceClassName(sourceClass);	lr.setSourceMethodName(sourceMethod);	Object params[] = { param1 };	lr.setParameters(params);	doLog(lr, bundleName);    }    /**     * Log a message, specifying source class, method, and resource bundle name,     * with an array of object arguments.     * <p>     * If the logger is currently enabled for the given message      * level then a corresponding LogRecord is created and forwarded      * to all the registered output Handler objects.     * <p>     * The msg string is localized using the named resource bundle.  If the     * resource bundle name is null, then the msg string is not localized.     * <p>     * @param	level   One of the message level identifiers, e.g. SEVERE     * @param   sourceClass    name of class that issued the logging request     * @param   sourceMethod   name of method that issued the logging request     * @param   bundleName     name of resource bundle to localize msg     * @param   msg	The string message (or a key in the message catalog)     * @param   params	Array of parameters to the message     * @throws  MissingResourceException if no suitable ResourceBundle can     *		be found.     */    public void logrb(Level level, String sourceClass, String sourceMethod,				String bundleName, String msg, Object params[]) {	if (level.intValue() < levelValue || levelValue == offValue) {	    return;	}	LogRecord lr = new LogRecord(level, msg);	lr.setSourceClassName(sourceClass);	lr.setSourceMethodName(sourceMethod);	lr.setParameters(params);	doLog(lr, bundleName);    }    /**     * Log a message, specifying source class, method, and resource bundle name,     * with associated Throwable information.     * <p>     * If the logger is currently enabled for the given message      * level then the given arguments are stored in a LogRecord     * which is forwarded to all registered output handlers.     * <p>     * The msg string is localized using the named resource bundle.  If the     * resource bundle name is null, then the msg string is not localized.     * <p>     * Note that the thrown argument is stored in the LogRecord thrown     * property, rather than the LogRecord parameters property.  Thus is it     * processed specially by output Formatters and is not treated     * as a formatting parameter to the LogRecord message property.     * <p>     * @param	level   One of the message level identifiers, e.g. SEVERE     * @param   sourceClass    name of class that issued the logging request     * @param   sourceMethod   name of method that issued the logging request     * @param   bundleName     name of resource bundle to localize msg     * @param   msg	The string message (or a key in the message catalog)     * @param   thrown  Throwable associated with log message.     * @throws  MissingResourceException if no suitable ResourceBundle can     *		be found.     */    public void logrb(Level level, String sourceClass, String sourceMethod,					String bundleName, String msg, Throwable thrown) {	if (level.intValue() < levelValue || levelValue == offValue) {	    return;	}	LogRecord lr = new LogRecord(level, msg);	lr.setSourceClassName(sourceClass);	lr.setSourceMethodName(sourceMethod);	lr.setThrown(thrown);	doLog(lr, bundleName);    }    //======================================================================    // Start of convenience methods for logging method entries and returns.    //======================================================================    /**     * Log a method entry.     * <p>     * This is a convenience method that can be used to log entry     * to a method.  A LogRecord with message "ENTRY", log level     * FINER, and the given sourceMethod and sourceClass is logged.     * <p>     * @param   sourceClass    name of class that issued the logging request     * @param   sourceMethod   name of method that is being entered     */    public void entering(String sourceClass, String sourceMethod) {	if (Level.FINER.intValue() < levelValue) {	    return;	}	logp(Level.FINER, sourceClass, sourceMethod, "ENTRY");    }    /**     * Log a method entry, with one parameter.     * <p>     * This is a convenience method that can be used to log entry     * to a method.  A LogRecord with message "ENTRY {0}", log level     * FINER, and the given sourceMethod, sourceClass, and parameter     * is logged.     * <p>     * @param   sourceClass    name of class that issued the logging request     * @param   sourceMethod   name of method that is being entered     * @param   param1	       parameter to the method being entered     */    public void entering(String sourceClass, String sourceMethod, Object param1) {	if (Level.FINER.intValue() < levelValue) {	    return;	}	Object params[] = { param1 };	logp(Level.FINER, sourceClass, sourceMethod, "ENTRY {0}", params);    }    /**     * Log a method entry, with an array of parameters.     * <p>     * This is a convenience method that can be used to log entry     * to a method.  A LogRecord with message "ENTRY" (followed by a      * format {N} indicator for each entry in the parameter array),      * log level FINER, and the given sourceMethod, sourceClass, and      * parameters is logged.     * <p>     * @param   sourceClass    name of class that issued the logging request     * @param   sourceMethod   name of method that is being entered     * @param   params	       array of parameters to the method being entered     */    public void entering(String sourceClass, String sourceMethod, Object params[]) {	if (Level.FINER.intValue() < levelValue) {	    return;	}	String msg = "ENTRY";	for (int i = 0; i < params.length; i++) {	    msg = msg + " {" + i + "}";	}	logp(Level.FINER, sourceClass, sourceMethod, msg, params);    }    /**     * Log a method return.     * <p>     * This is a convenience method that can be used to log returning     * from a method.  A LogRecord with message "RETURN", log level     * FINER, and the given sourceMethod and sourceClass is logged.     * <p>     * @param   sourceClass    name of class that issued the logging request     * @param   sourceMethod   name of the method      */    public void exiting(String sourceClass, String sourceMethod) {	if (Level.FINER.intValue() < levelValue) {	    return;	}	logp(Level.FINER, sourceClass, sourceMethod, "RETURN");    }    /**     * Log a method return, with result object.     * <p>     * This is a convenience method that can be used to log returning     * from a method.  A LogRecord with message "RETURN {0}", log level     * FINER, and the gives sourceMethod, sourceClass, and result     * object is logged.     * <p>     * @param   sourceClass    name of class that issued the logging request     * @param   sourceMethod   name of the method      * @param   result  Object that is being returned     */    public void exiting(String sourceClass, String sourceMethod, Object result) {	if (Level.FINER.intValue() < levelValue) {	    return;	} 	Object params[] = { result };	logp(Level.FINER, sourceClass, sourceMethod, "RETURN {0}", result);    }    /**     * Log throwing an exception.     * <p>     * This is a convenience method to log that a method is     * terminating by throwing an exception.  The logging is done      * using the FINER level.     * <p>     * If the logger is currently enabled for the given message      * level then the given arguments are stored in a LogRecord     * which is forwarded to all registered output handlers.  The     * LogRecord's message is set to "THROW".     * <p>     * Note that the thrown argument is stored in the LogRecord thrown     * property, rather than the LogRecord parameters property.  Thus is it     * processed specially by output Formatters and is not treated     * as a formatting parameter to the LogRecord message property.     * <p>     * @param   sourceClass    name of class that issued the logging request     * @param   sourceMethod  name of the method.     * @param   thrown  The Throwable that is being thrown.     */    public void throwing(String sourceClass, String sourceMethod, Throwable thrown) {	if (Level.FINER.intValue() < levelValue) {	    return;	}	LogRecord lr = new LogRecord(Level.FINER, "THROW");	lr.setSourceClassName(sourceClass);	lr.setSourceMethodName(sourceMethod);	lr.setThrown(thrown);	doLog(lr);    }    //=======================================================================    // Start of simple convenience methods using level names as method names    //=======================================================================    /**     * Log a SEVERE message.     * <p>     * If the logger is currently enabled for the SEVERE message      * level then the given message is forwarded to all the     * registered output Handler objects.     * <p>     * @param   msg	The string message (or a key in the message catalog)     */    public void severe(String msg) {	if (Level.SEVERE.intValue() < levelValue) {	    return;	}	log(Level.SEVERE, msg);    }    /**     * Log a WARNING message.     * <p>     * If the logger is currently enabled for the WARNING message      * level then the given message is forwarded to all the     * registered output Handler objects.     * <p>     * @param   msg	The string message (or a key in the message catalog)     */    public void warning(String msg) {	if (Level.WARNING.intValue() < levelValue) {	    return;	}	log(Level.WARNING, msg);    }    /**     * Log an INFO message.     * <p>     * If the logger is currently enabled for the INFO message      * level then the given message is forwarded to all the     * registered output Handler objects.     * <p>     * @param   msg	The string message (or a key in the message catalog)     */    public void info(String msg) {	if (Level.INFO.intValue() < levelValue) {	    return;	}	log(Level.INFO, msg);    }    /**     * Log a CONFIG message.     * <p>     * If the logger is currently enabled for the CONFIG message      * level then the given message is forwarded to all the     * registered output Handler objects.     * <p>     * @param   msg	The string message (or a key in the message catalog)     */    public void config(String msg) {	if (Level.CONFIG.intValue() < levelValue) {	    return;	}	log(Level.CONFIG, msg);    }    /**     * Log a FINE message.     * <p>     * If the logger is currently enabled for the FINE message      * level then the given message is forwarded to all the     * registered output Handler objects.     * <p>     * @param   msg	The string message (or a key in the message catalog)     */    public void fine(String msg) {	if (Level.FINE.intValue() < levelValue) {	    return;	}	log(Level.FINE, msg);    }    /**     * Log a FINER message.     * <p>     * If the logger is currently enabled for the FINER message      * level then the given message is forwarded to all the     * registered output Handler objects.     * <p>     * @param   msg	The string message (or a key in the message catalog)     */    public void finer(String msg) {	if (Level.FINER.intValue() < levelValue) {	    return;	}	log(Level.FINER, msg);    }    /**     * Log a FINEST message.     * <p>     * If the logger is currently enabled for the FINEST message      * level then the given message is forwarded to all the     * registered output Handler objects.     * <p>     * @param   msg	The string message (or a key in the message catalog)     */    public void finest(String msg) {	if (Level.FINEST.intValue() < levelValue) {	    return;	}	log(Level.FINEST, msg);    }    //================================================================    // End of convenience methods     //================================================================    /**     * Set the log level specifying which message levels will be     * logged by this logger.  Message levels lower than this     * value will be discarded.  The level value Level.OFF     * can be used to turn off logging.     * <p>     * If the new level is null, it means that this node should     * inherit its level from its nearest ancestor with a specific     * (non-null) level value.     *      * @param newLevel   the new value for the log level (may be null)     * @exception  SecurityException  if a security manager exists and if     *             the caller does not have LoggingPermission("control").     */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -