Class Category

  • All Implemented Interfaces:
    AppenderAttachable
    Direct Known Subclasses:
    Logger

    public class Category
    extends java.lang.Object
    implements AppenderAttachable
    Implementation of the Category class for compatibility, despite it having been deprecated a long, long time ago.
    • Field Detail

      • FQCN

        private static final java.lang.String FQCN
      • name

        protected java.lang.String name
        The name of this category.
      • additive

        protected boolean additive
        Additivity is set to true by default, that is children inherit the appenders of their ancestors by default. If this variable is set to false then the appenders found in the ancestors of this category are not used. However, the children of this category will inherit its appenders, unless the children have their additivity flag set to false too. See the user manual for more details.
      • level

        protected volatile Level level
        The assigned level of this category. The level variable need not be assigned a value in which case it is inherited form the hierarchy.
      • parent

        protected volatile Category parent
        The parent of this category. All categories have at least one ancestor which is the root category.
      • bundle

        protected java.util.ResourceBundle bundle
        Resource bundle for localized messages.
      • logger

        private final Logger logger
      • repository

        protected LoggerRepository repository
        Categories need to know what Hierarchy they are in.
    • Constructor Detail

      • Category

        protected Category​(LoggerContext context,
                           java.lang.String name)
        Constructor used by Logger to specify a LoggerContext.
        Parameters:
        context - The LoggerContext.
        name - The name of the Logger.
      • Category

        Category​(Logger logger)
      • Category

        protected Category​(java.lang.String name)
        Constructor exposed by Log4j 1.2.
        Parameters:
        name - The name of the Logger.
    • Method Detail

      • exists

        @Deprecated
        public static Logger exists​(java.lang.String name)
        Deprecated.
        Please use LogManager.exists(String) instead.
        Tests if the named category exists (in the default hierarchy).
        Parameters:
        name - The name to test.
        Returns:
        Whether the name exists.
        Since:
        0.8.5
      • getCurrentCategories

        @Deprecated
        public static java.util.Enumeration getCurrentCategories()
        Deprecated.
        Please use LogManager.getCurrentLoggers() instead.
        Returns all the currently defined categories in the default hierarchy as an Enumeration.

        The root category is not included in the returned Enumeration.

        Returns:
        and Enumeration of the Categories.
      • getDefaultHierarchy

        @Deprecated
        public static LoggerRepository getDefaultHierarchy()
        Deprecated.
        Gets the default LoggerRepository instance.
        Returns:
        the default LoggerRepository instance.
        Since:
        1.0
      • getInstance

        public static Category getInstance​(java.lang.Class clazz)
      • getInstance

        public static Category getInstance​(java.lang.String name)
      • getRoot

        public static Category getRoot()
      • getSubName

        private static java.lang.String getSubName​(java.lang.String name)
      • shutdown

        public static void shutdown()
        Shuts down the current configuration.
      • addAppender

        public void addAppender​(Appender appender)
        Add newAppender to the list of appenders of this Category instance.

        If newAppender is already in the list of appenders, then it won't be added again.

        Specified by:
        addAppender in interface AppenderAttachable
        Parameters:
        appender - The Appender to add.
      • assertLog

        public void assertLog​(boolean assertion,
                              java.lang.String msg)
        If assertion parameter is false, then logs msg as an error statement.

        The assert method has been renamed to assertLog because assert is a language reserved word in JDK 1.4.

        Parameters:
        assertion - The assertion.
        msg - The message to print if assertion is false.
        Since:
        1.2
      • callAppenders

        public void callAppenders​(LoggingEvent event)
        Call the appenders in the hierrachy starting at this. If no appenders could be found, emit a warning.

        This method calls all the appenders inherited from the hierarchy circumventing any evaluation of whether to log or not to log the particular log request.

        Parameters:
        event - the event to log.
      • closeNestedAppenders

        void closeNestedAppenders()
        Closes all attached appenders implementing the AppenderAttachable interface.
        Since:
        1.0
      • debug

        public void debug​(java.lang.Object message)
      • debug

        public void debug​(java.lang.Object message,
                          java.lang.Throwable t)
      • error

        public void error​(java.lang.Object message)
      • error

        public void error​(java.lang.Object message,
                          java.lang.Throwable t)
      • fatal

        public void fatal​(java.lang.Object message)
      • fatal

        public void fatal​(java.lang.Object message,
                          java.lang.Throwable t)
      • fireRemoveAppenderEvent

        private void fireRemoveAppenderEvent​(Appender appender)
        LoggerRepository forgot the fireRemoveAppenderEvent method, if using the stock Hierarchy implementation, then call its fireRemove. Custom repositories can implement HierarchyEventListener if they want remove notifications.
        Parameters:
        appender - appender, may be null.
      • createMessage

        private static Message createMessage​(java.lang.Object message)
      • forcedLog

        public void forcedLog​(java.lang.String fqcn,
                              Priority level,
                              java.lang.Object message,
                              java.lang.Throwable t)
      • getAdditivity

        public boolean getAdditivity()
      • getAllAppenders

        public java.util.Enumeration getAllAppenders()
        Get all the Log4j 1.x appenders contained in this category as an Enumeration. Log4j 2.x appenders are omitted.
        Specified by:
        getAllAppenders in interface AppenderAttachable
        Returns:
        Enumeration An enumeration of the appenders in this category.
      • getAppender

        public Appender getAppender​(java.lang.String name)
        Look for the appender named as name.

        Return the appender with that name if in the list. Return null otherwise.

        Specified by:
        getAppender in interface AppenderAttachable
        Parameters:
        name - The name of the Appender.
        Returns:
        The Appender.
      • getChainedPriority

        public Priority getChainedPriority()
      • getEffectiveLevel

        public Level getEffectiveLevel()
      • getLevel

        public final Level getLevel()
      • getLevelStr

        private java.lang.String getLevelStr​(Priority priority)
      • getLogger

        Logger getLogger()
      • getName

        public final java.lang.String getName()
      • getParent

        public final Category getParent()
      • getPriority

        public final Level getPriority()
      • getResourceBundle

        public java.util.ResourceBundle getResourceBundle()
      • info

        public void info​(java.lang.Object message)
      • info

        public void info​(java.lang.Object message,
                         java.lang.Throwable t)
      • isAttached

        public boolean isAttached​(Appender appender)
        Is the appender passed as parameter attached to this category?
        Specified by:
        isAttached in interface AppenderAttachable
        Parameters:
        appender - The Appender to add.
        Returns:
        true if the appender is attached.
      • isDebugEnabled

        public boolean isDebugEnabled()
      • isEnabledFor

        private boolean isEnabledFor​(Level level)
      • isEnabledFor

        public boolean isEnabledFor​(Priority level)
      • isErrorEnabled

        public boolean isErrorEnabled()
      • isFatalEnabled

        public boolean isFatalEnabled()
      • isInfoEnabled

        public boolean isInfoEnabled()
      • isWarnEnabled

        public boolean isWarnEnabled()
      • l7dlog

        public void l7dlog​(Priority priority,
                           java.lang.String key,
                           java.lang.Object[] params,
                           java.lang.Throwable t)
      • l7dlog

        public void l7dlog​(Priority priority,
                           java.lang.String key,
                           java.lang.Throwable t)
      • log

        public void log​(Priority priority,
                        java.lang.Object message)
      • log

        public void log​(Priority priority,
                        java.lang.Object message,
                        java.lang.Throwable t)
      • log

        public void log​(java.lang.String fqcn,
                        Priority priority,
                        java.lang.Object message,
                        java.lang.Throwable t)
      • maybeLog

        void maybeLog​(java.lang.String fqcn,
                      Level level,
                      java.lang.Object message,
                      java.lang.Throwable throwable)
      • removeAllAppenders

        public void removeAllAppenders()
        Removes all previously added appenders from this Category instance.

        This is useful when re-reading configuration information.

        Specified by:
        removeAllAppenders in interface AppenderAttachable
      • removeAppender

        public void removeAppender​(Appender appender)
        Removes the appender passed as parameter form the list of appenders.
        Specified by:
        removeAppender in interface AppenderAttachable
        Parameters:
        appender - The Appender to remove.
        Since:
        0.8.2
      • removeAppender

        public void removeAppender​(java.lang.String name)
        Removes the appender with the name passed as parameter form the list of appenders.
        Specified by:
        removeAppender in interface AppenderAttachable
        Parameters:
        name - The Appender to remove.
        Since:
        0.8.2
      • searchInterfaces

        ObjectRenderer searchInterfaces​(java.lang.Class<?> c)
      • setAdditivity

        public void setAdditivity​(boolean additivity)
      • setHierarchy

        final void setHierarchy​(LoggerRepository repository)
        Only the Hiearchy class can set the hiearchy of a category. Default package access is MANDATORY here.
      • setLevel

        public void setLevel​(Level level)
      • setLevel

        private void setLevel​(Level level)
      • setPriority

        public void setPriority​(Priority priority)
      • setResourceBundle

        public void setResourceBundle​(java.util.ResourceBundle bundle)
      • warn

        public void warn​(java.lang.Object message)
      • warn

        public void warn​(java.lang.Object message,
                         java.lang.Throwable t)