JBoss LogManager 1.1.0.CR6

org.jboss.logmanager
Class Logger

java.lang.Object
  extended by java.util.logging.Logger
      extended by org.jboss.logmanager.Logger
All Implemented Interfaces:
Serializable

public final class Logger
extends Logger
implements Serializable

An actual logger instance. This is the end-user interface into the logging system.

See Also:
Serialized Form

Nested Class Summary
static class Logger.AttachmentKey<V>
          An attachment key instance.
 
Field Summary
 
Fields inherited from class java.util.logging.Logger
global, GLOBAL_LOGGER_NAME
 
Method Summary
 void addHandler(Handler handler)
          
<V> V
attach(Logger.AttachmentKey<V> key, V value)
          Attach an object to this logger under a given key.
<V> V
attachIfAbsent(Logger.AttachmentKey<V> key, V value)
          Attach an object to this logger under a given key, if such an attachment does not already exist.
 Handler[] clearHandlers()
          A convenience method to atomically get and clear all handlers.
 void config(String msg)
          
<V> V
detach(Logger.AttachmentKey<V> key)
          Remove an attachment.
 void entering(String sourceClass, String sourceMethod)
          
 void entering(String sourceClass, String sourceMethod, Object param1)
          
 void entering(String sourceClass, String sourceMethod, Object[] params)
          
 void exiting(String sourceClass, String sourceMethod)
          
 void exiting(String sourceClass, String sourceMethod, Object result)
          
protected  void finalize()
          Perform finalization actions.
 void fine(String msg)
          
 void finer(String msg)
          
 void finest(String msg)
          
<V> V
getAttachment(Logger.AttachmentKey<V> key)
          Get the attachment value for a given key, or null if there is no such attachment.
 int getEffectiveLevel()
          Get the effective numerical log level, inherited from the parent.
 Filter getFilter()
          
 Handler[] getHandlers()
          
 Level getLevel()
          
static Logger getLogger(String name)
          Static logger factory method which returns a JBoss LogManager logger.
static Logger getLogger(String name, String bundleName)
          Static logger factory method which returns a JBoss LogManager logger.
 Logger getParent()
          
 boolean getUseParentHandlers()
          
 void info(String msg)
          
 boolean isLoggable(Level level)
          
 void log(Level level, String msg)
          
 void log(Level level, String msg, Object param1)
          
 void log(Level level, String msg, Object[] params)
          
 void log(Level level, String msg, Throwable thrown)
          
 void log(LogRecord record)
          
 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.
 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.
 void log(String fqcn, Level level, String message, Throwable t)
          SPI interface method to log a message at a given level.
 void logp(Level level, String sourceClass, String sourceMethod, String msg)
          
 void logp(Level level, String sourceClass, String sourceMethod, String msg, Object param1)
          
 void logp(Level level, String sourceClass, String sourceMethod, String msg, Object[] params)
          
 void logp(Level level, String sourceClass, String sourceMethod, String msg, Throwable thrown)
          
 void logRaw(ExtLogRecord record)
          Do the logging with no level checks (they've already been done).
 void logRaw(LogRecord record)
          Do the logging with no level checks (they've already been done).
 void logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msg)
          
 void logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msg, Object param1)
          
 void logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msg, Object[] params)
          
 void logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msg, Throwable thrown)
          
 void removeHandler(Handler handler)
          
 void setFilter(Filter filter)
          
 void setLevel(Level newLevel)
           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).
 void setLevelName(String newLevelName)
          Set the log level by name.
 void setParent(Logger parent)
          Not allowed. This method may never be called.
 void setUseParentHandlers(boolean useParentHandlers)
          
 void severe(String msg)
          
 void throwing(String sourceClass, String sourceMethod, Throwable thrown)
          
 String toString()
           
 void warning(String msg)
          
 
Methods inherited from class java.util.logging.Logger
getAnonymousLogger, getAnonymousLogger, getName, getResourceBundle, getResourceBundleName
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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

setFilter

public void setFilter(Filter filter)
               throws SecurityException

Overrides:
setFilter in class Logger
Throws:
SecurityException

getFilter

public Filter getFilter()

Overrides:
getFilter in class 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

getLevel

public Level getLevel()

Overrides:
getLevel in class Logger

isLoggable

public boolean isLoggable(Level level)

Overrides:
isLoggable in class Logger

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)

addHandler

public void addHandler(Handler handler)
                throws SecurityException

Overrides:
addHandler in class Logger
Throws:
SecurityException

removeHandler

public void removeHandler(Handler handler)
                   throws SecurityException

Overrides:
removeHandler in class Logger
Throws:
SecurityException

getHandlers

public Handler[] getHandlers()

Overrides:
getHandlers in class Logger

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

getUseParentHandlers

public boolean getUseParentHandlers()

Overrides:
getUseParentHandlers in class Logger

getParent

public Logger getParent()

Overrides:
getParent in class Logger

setParent

public void setParent(Logger parent)
Not allowed. This method may never be called.

Overrides:
setParent in class Logger
Throws:
SecurityException - always

log

public void log(LogRecord record)

Overrides:
log in class Logger

entering

public void entering(String sourceClass,
                     String sourceMethod)

Overrides:
entering in class Logger

entering

public void entering(String sourceClass,
                     String sourceMethod,
                     Object param1)

Overrides:
entering in class Logger

entering

public void entering(String sourceClass,
                     String sourceMethod,
                     Object[] params)

Overrides:
entering in class Logger

exiting

public void exiting(String sourceClass,
                    String sourceMethod)

Overrides:
exiting in class Logger

exiting

public void exiting(String sourceClass,
                    String sourceMethod,
                    Object result)

Overrides:
exiting in class Logger

throwing

public void throwing(String sourceClass,
                     String sourceMethod,
                     Throwable thrown)

Overrides:
throwing in class Logger

severe

public void severe(String msg)

Overrides:
severe in class Logger

warning

public void warning(String msg)

Overrides:
warning in class Logger

info

public void info(String msg)

Overrides:
info in class Logger

config

public void config(String msg)

Overrides:
config in class Logger

fine

public void fine(String msg)

Overrides:
fine in class Logger

finer

public void finer(String msg)

Overrides:
finer in class Logger

finest

public void finest(String msg)

Overrides:
finest in class Logger

log

public void log(Level level,
                String msg)

Overrides:
log in class Logger

log

public void log(Level level,
                String msg,
                Object param1)

Overrides:
log in class Logger

log

public void log(Level level,
                String msg,
                Object[] params)

Overrides:
log in class Logger

log

public void log(Level level,
                String msg,
                Throwable thrown)

Overrides:
log in class Logger

logp

public void logp(Level level,
                 String sourceClass,
                 String sourceMethod,
                 String msg)

Overrides:
logp in class Logger

logp

public void logp(Level level,
                 String sourceClass,
                 String sourceMethod,
                 String msg,
                 Object param1)

Overrides:
logp in class Logger

logp

public void logp(Level level,
                 String sourceClass,
                 String sourceMethod,
                 String msg,
                 Object[] params)

Overrides:
logp in class Logger

logp

public void logp(Level level,
                 String sourceClass,
                 String sourceMethod,
                 String msg,
                 Throwable thrown)

Overrides:
logp in class Logger

logrb

public void logrb(Level level,
                  String sourceClass,
                  String sourceMethod,
                  String bundleName,
                  String msg)

Overrides:
logrb in class Logger

logrb

public void logrb(Level level,
                  String sourceClass,
                  String sourceMethod,
                  String bundleName,
                  String msg,
                  Object param1)

Overrides:
logrb in class Logger

logrb

public void logrb(Level level,
                  String sourceClass,
                  String sourceMethod,
                  String bundleName,
                  String msg,
                  Object[] params)

Overrides:
logrb in class Logger

logrb

public void logrb(Level level,
                  String sourceClass,
                  String sourceMethod,
                  String bundleName,
                  String msg,
                  Throwable thrown)

Overrides:
logrb in class Logger

finalize

protected void finalize()
                 throws Throwable
Perform finalization actions. This amounts to clearing out the loglevel so that all children are updated with the parent's effective loglevel. As such, a lock is acquired from this method which might cause delays in garbage collection.

Overrides:
finalize in class Object
Throws:
Throwable

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

toString

public String toString()
Overrides:
toString in class Object

JBoss LogManager 1.1.0.CR6

Copyright © 2009 JBoss, a division of Red Hat, Inc.