Class Logger

    • Method Detail

      • getLogger

        public static Logger getLogger​(String name)
        Static logger factory method which returns a JBoss LogManager logger.
        Parameters:
        name - the logger name
        Returns:
        the logger
      • getLogger

        public static Logger getLogger​(String name,
                                       String bundleName)
        Static logger factory method which returns a JBoss LogManager logger.
        Parameters:
        name - the logger name
        bundleName - the bundle name
        Returns:
        the logger
      • setLevel

        public void setLevel​(Level newLevel)
                      throws SecurityException
        This implementation grabs a lock, so that only one thread may update the log level of any logger at a time, in order to allow readers to never block (though there is a window where retrieving the log level reflects an older effective level than the actual level).
        Overrides:
        setLevel in class Logger
        Throws:
        SecurityException
      • setLevelName

        public void setLevelName​(String newLevelName)
                          throws SecurityException
        Set the log level by name. Uses the parent logging context's name registry; otherwise behaves identically to setLevel(Level).
        Parameters:
        newLevelName - the name of the level to set
        Throws:
        SecurityException - if a security manager exists and if the caller does not have LoggingPermission("control")
      • getEffectiveLevel

        public int getEffectiveLevel()
        Get the effective numerical log level, inherited from the parent.
        Returns:
        the effective level
      • getAttachment

        public <V> V getAttachment​(Logger.AttachmentKey<V> key)
        Get the attachment value for a given key, or null if there is no such attachment.
        Type Parameters:
        V - the attachment value type
        Parameters:
        key - the key
        Returns:
        the attachment, or null if there is none for this key
      • attach

        public <V> V attach​(Logger.AttachmentKey<V> key,
                            V value)
                     throws SecurityException
        Attach an object to this logger under a given key. A strong reference is maintained to the key and value for as long as this logger exists.
        Type Parameters:
        V - the attachment value type
        Parameters:
        key - the attachment key
        value - the attachment value
        Returns:
        the old attachment, if there was one
        Throws:
        SecurityException - if a security manager exists and if the caller does not have LoggingPermission(control)
      • attachIfAbsent

        public <V> V attachIfAbsent​(Logger.AttachmentKey<V> key,
                                    V value)
                             throws SecurityException
        Attach an object to this logger under a given key, if such an attachment does not already exist. A strong reference is maintained to the key and value for as long as this logger exists.
        Type Parameters:
        V - the attachment value type
        Parameters:
        key - the attachment key
        value - the attachment value
        Returns:
        the current attachment, if there is one, or null if the value was successfully attached
        Throws:
        SecurityException - if a security manager exists and if the caller does not have LoggingPermission(control)
      • detach

        public <V> V detach​(Logger.AttachmentKey<V> key)
                     throws SecurityException
        Remove an attachment.
        Type Parameters:
        V - the attachment value type
        Parameters:
        key - the attachment key
        Returns:
        the old value, or null if there was none
        Throws:
        SecurityException - if a security manager exists and if the caller does not have LoggingPermission(control)
      • setHandlers

        public void setHandlers​(Handler[] handlers)
                         throws SecurityException
        A convenience method to atomically replace the handler list for this logger.
        Parameters:
        handlers - the new handlers
        Throws:
        SecurityException - if a security manager exists and if the caller does not have LoggingPermission(control)
      • getAndSetHandlers

        public Handler[] getAndSetHandlers​(Handler[] handlers)
                                    throws SecurityException
        Atomically get and set the handler list for this logger.
        Parameters:
        handlers - the new handler set
        Returns:
        the old handler set
        Throws:
        SecurityException - if a security manager exists and if the caller does not have LoggingPermission(control)
      • compareAndSetHandlers

        public boolean compareAndSetHandlers​(Handler[] expected,
                                             Handler[] newHandlers)
                                      throws SecurityException
        Atomically compare and set the handler list for this logger.
        Parameters:
        expected - the expected list of handlers
        newHandlers - the replacement list of handlers
        Returns:
        true if the handler list was updated or false if the current handlers did not match the expected handlers list
        Throws:
        SecurityException - if a security manager exists and if the caller does not have LoggingPermission(control)
      • clearHandlers

        public Handler[] clearHandlers()
                                throws SecurityException
        A convenience method to atomically get and clear all handlers.
        Throws:
        SecurityException - if a security manager exists and if the caller does not have LoggingPermission(control)
      • setUseParentHandlers

        public void setUseParentHandlers​(boolean useParentHandlers)
        Overrides:
        setUseParentHandlers in class Logger
      • setUseParentFilters

        public void setUseParentFilters​(boolean useParentFilter)
        Specify whether or not filters should be inherited from parent loggers.

        Setting this value to false has the same behaviour as Logger.

        Parameters:
        useParentFilter - true to inherit a parents filter, otherwise false
      • getUseParentFilters

        public boolean getUseParentFilters()
        Indicates whether or not this logger inherits filters from it's parent logger.
        Returns:
        true if filters are inherited, otherwise false
      • getLogContext

        public LogContext getLogContext()
        Get the log context to which this logger belongs.
        Returns:
        the log context
      • log

        public void log​(String fqcn,
                        Level level,
                        String message,
                        String bundleName,
                        ExtLogRecord.FormatStyle style,
                        Object[] params,
                        Throwable t)
        SPI interface method to log a message at a given level, with a specific resource bundle.
        Parameters:
        fqcn - the fully qualified class name of the first logger class
        level - the level to log at
        message - the message
        bundleName - the resource bundle name
        style - the message format style
        params - the log parameters
        t - the throwable, if any
      • log

        public void log​(String fqcn,
                        Level level,
                        String message,
                        ExtLogRecord.FormatStyle style,
                        Object[] params,
                        Throwable t)
        SPI interface method to log a message at a given level.
        Parameters:
        fqcn - the fully qualified class name of the first logger class
        level - the level to log at
        message - the message
        style - the message format style
        params - the log parameters
        t - the throwable, if any
      • log

        public void log​(String fqcn,
                        Level level,
                        String message,
                        Throwable t)
        SPI interface method to log a message at a given level.
        Parameters:
        fqcn - the fully qualified class name of the first logger class
        level - the level to log at
        message - the message
        t - the throwable, if any
      • logRaw

        public void logRaw​(ExtLogRecord record)
        Do the logging with no level checks (they've already been done).
        Parameters:
        record - the extended log record
      • logRaw

        public void logRaw​(LogRecord record)
        Do the logging with no level checks (they've already been done). Creates an extended log record if the provided record is not one.
        Parameters:
        record - the log record