?? category.java
字號:
print a stack trace use the {@link #fatal(Object, Throwable)} form instead. @param message the message object to log */ public void fatal(Object message) { if(repository.isDisabled(Level.FATAL_INT)) return; if(Level.FATAL.isGreaterOrEqual(this.getEffectiveLevel())) forcedLog(FQCN, Level.FATAL, message, null); } /** Log a message object with the <code>FATAL</code> level including the stack trace of the {@link Throwable} <code>t</code> passed as parameter. <p>See {@link #fatal(Object)} for more detailed information. @param message the message object to log. @param t the exception to log, including its stack trace. */ public void fatal(Object message, Throwable t) { if(repository.isDisabled(Level.FATAL_INT)) return; if(Level.FATAL.isGreaterOrEqual(this.getEffectiveLevel())) forcedLog(FQCN, Level.FATAL, message, t); } /** This method creates a new logging event and logs the event without further checks. */ protected void forcedLog(String fqcn, Priority level, Object message, Throwable t) { callAppenders(new LoggingEvent(fqcn, this, level, message, t)); } /** Get the additivity flag for this Category instance. */ public boolean getAdditivity() { return additive; } /** Get the appenders contained in this category as an {@link Enumeration}. If no appenders can be found, then a {@link NullEnumeration} is returned. @return Enumeration An enumeration of the appenders in this category. */ synchronized public Enumeration getAllAppenders() { if(aai == null) return NullEnumeration.getInstance(); else return aai.getAllAppenders(); } /** Look for the appender named as <code>name</code>. <p>Return the appender with that name if in the list. Return <code>null</code> otherwise. */ synchronized public Appender getAppender(String name) { if(aai == null || name == null) return null; return aai.getAppender(name); } /** Starting from this category, search the category hierarchy for a non-null level and return it. Otherwise, return the level of the root category. <p>The Category class is designed so that this method executes as quickly as possible. */ public Level getEffectiveLevel() { for(Category c = this; c != null; c=c.parent) { if(c.level != null) return c.level; } return null; // If reached will cause an NullPointerException. } /** * * @deprecated Please use the the {@link #getEffectiveLevel} method * instead. * */ public Priority getChainedPriority() { for(Category c = this; c != null; c=c.parent) { if(c.level != null) return c.level; } return null; // If reached will cause an NullPointerException. } /** Returns all the currently defined categories in the default hierarchy as an {@link java.util.Enumeration Enumeration}. <p>The root category is <em>not</em> included in the returned {@link Enumeration}. @deprecated Please use {@link LogManager#getCurrentLoggers()} instead. */ public static Enumeration getCurrentCategories() { return LogManager.getCurrentLoggers(); } /** Return the default Hierarchy instance. @deprecated Please use {@link LogManager#getLoggerRepository()} instead. @since 1.0 */ public static LoggerRepository getDefaultHierarchy() { return LogManager.getLoggerRepository(); } /** Return the the {@link Hierarchy} where this <code>Category</code> instance is attached. @deprecated Please use {@link #getLoggerRepository} instead. @since 1.1 */ public LoggerRepository getHierarchy() { return repository; } /** Return the the {@link LoggerRepository} where this <code>Category</code> is attached. @since 1.2 */ public LoggerRepository getLoggerRepository() { return repository; } /** * @deprecated Make sure to use {@link Logger#getLogger(String)} instead. */ public static Category getInstance(String name) { return LogManager.getLogger(name); } /** * @deprecated Please make sure to use {@link Logger#getLogger(Class)} instead. */ public static Category getInstance(Class clazz) { return LogManager.getLogger(clazz); } /** Return the category name. */ public final String getName() { return name; } /** Returns the parent of this category. Note that the parent of a given category may change during the lifetime of the category. <p>The root category will return <code>null</code>. @since 1.2 */ final public Category getParent() { return this.parent; } /** Returns the assigned {@link Level}, if any, for this Category. @return Level - the assigned Level, can be <code>null</code>. */ final public Level getLevel() { return this.level; } /** @deprecated Please use {@link #getLevel} instead. */ final public Level getPriority() { return this.level; } /** * @deprecated Please use {@link Logger#getRootLogger()} instead. */ final public static Category getRoot() { return LogManager.getRootLogger(); } /** Return the <em>inherited</em> {@link ResourceBundle} for this category. <p>This method walks the hierarchy to find the appropriate resource bundle. It will return the resource bundle attached to the closest ancestor of this category, much like the way priorities are searched. In case there is no bundle in the hierarchy then <code>null</code> is returned. @since 0.9.0 */ public ResourceBundle getResourceBundle() { for(Category c = this; c != null; c=c.parent) { if(c.resourceBundle != null) return c.resourceBundle; } // It might be the case that there is no resource bundle return null; } /** Returns the string resource coresponding to <code>key</code> in this category's inherited resource bundle. See also {@link #getResourceBundle}. <p>If the resource cannot be found, then an {@link #error error} message will be logged complaining about the missing resource. */ protected String getResourceBundleString(String key) { ResourceBundle rb = getResourceBundle(); // This is one of the rare cases where we can use logging in order // to report errors from within log4j. if(rb == null) { //if(!hierarchy.emittedNoResourceBundleWarning) { //error("No resource bundle has been set for category "+name); //hierarchy.emittedNoResourceBundleWarning = true; //} return null; } else { try { return rb.getString(key); } catch(MissingResourceException mre) { error("No resource is associated with key \""+key+"\"."); return null; } } } /** Log a message object with the {@link Level#INFO INFO} Level. <p>This method first checks if this category is <code>INFO</code> enabled by comparing the level of this category with {@link Level#INFO INFO} Level. If the category is <code>INFO</code> enabled, then it converts the message object passed as parameter to a string by invoking the appropriate {@link org.apache.log4j.or.ObjectRenderer}. It proceeds to call all the registered appenders in this category and also higher in the hierarchy depending on the value of the additivity flag. <p><b>WARNING</b> Note that passing a {@link Throwable} to this method will print the name of the Throwable but no stack trace. To print a stack trace use the {@link #info(Object, Throwable)} form instead. @param message the message object to log */ public void info(Object message) { if(repository.isDisabled(Level.INFO_INT)) return; if(Level.INFO.isGreaterOrEqual(this.getEffectiveLevel())) forcedLog(FQCN, Level.INFO, message, null); } /** Log a message object with the <code>INFO</code> level including the stack trace of the {@link Throwable} <code>t</code> passed as parameter. <p>See {@link #info(Object)} for more detailed information. @param message the message object to log. @param t the exception to log, including its stack trace. */ public void info(Object message, Throwable t) { if(repository.isDisabled(Level.INFO_INT)) return; if(Level.INFO.isGreaterOrEqual(this.getEffectiveLevel())) forcedLog(FQCN, Level.INFO, message, t); } /** Is the appender passed as parameter attached to this category? */ public boolean isAttached(Appender appender) { if(appender == null || aai == null) return false; else { return aai.isAttached(appender); } } /** * Check whether this category is enabled for the <code>DEBUG</code> * Level. * * <p> This function is intended to lessen the computational cost of * disabled log debug statements. * * <p> For some <code>cat</code> Category object, when you write, * <pre> * cat.debug("This is entry number: " + i ); * </pre> * * <p>You incur the cost constructing the message, concatenatiion in
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -