Class Logger
java.lang.Object
java.util.logging.Logger
org.jboss.logmanager.Logger
- All Implemented Interfaces:
Serializable
An actual logger instance. This is the end-user interface into the logging system.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classAn attachment key instance. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final int(package private) static final int(package private) static final int(package private) static final int(package private) static final intprivate static final Stringprivate final LoggerNodeThe named logger tree node.(package private) static final intprivate static final long(package private) static final int(package private) static final intFields inherited from class Logger
global, GLOBAL_LOGGER_NAME -
Constructor Summary
ConstructorsConstructorDescriptionLogger(LoggerNode loggerNode, String name) Construct a new instance of an actual logger. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHandler(Handler handler) <V> Vattach(Logger.AttachmentKey<V> key, V value) Attach an object to this logger under a given key.<V> VattachIfAbsent(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[]A convenience method to atomically get and clear all handlers.booleancompareAndSetHandlers(Handler[] expected, Handler[] newHandlers) Atomically compare and set the handler list for this logger.void<V> Vdetach(Logger.AttachmentKey<V> key) Remove an attachment.voidvoidvoidvoidvoidprotected voidfinalize()voidvoidvoidHandler[]getAndSetHandlers(Handler[] handlers) Atomically get and set the handler list for this logger.<V> VgetAttachment(Logger.AttachmentKey<V> key) Get the attachment value for a given key, ornullif there is no such attachment.intGet the effective numerical log level, inherited from the parent.Handler[]getLevel()Get the log context to which this logger belongs.static LoggerStatic logger factory method which returns a JBoss LogManager logger.static LoggerStatic logger factory method which returns a JBoss LogManager logger.booleanIndicates whether or not this logger inherits filters from it's parent logger.booleanvoidbooleanisLoggable(Level level) voidlog(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.voidSPI interface method to log a message at a given level.voidlog(String fqcn, Level level, String message, ExtLogRecord.FormatStyle style, Object[] params, Throwable t) SPI interface method to log a message at a given level.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidDo the logging with no level checks (they've already been done).voidlogRaw(ExtLogRecord record) Do the logging with no level checks (they've already been done).voidvoidlogrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msg, Object param1) voidlogrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msg, Object[] params) voidlogrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msg, Throwable thrown) voidremoveHandler(Handler handler) voidvoidsetHandlers(Handler[] handlers) A convenience method to atomically replace the handler list for this logger.voidThis 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).voidsetLevelName(String newLevelName) Set the log level by name.voidNot allowed. This method may never be called.voidsetUseParentFilters(boolean useParentFilter) Specify whether or not filters should be inherited from parent loggers.voidsetUseParentHandlers(boolean useParentHandlers) voidvoidtoString()voidprotected final ObjectMethods inherited from class Logger
config, fine, finer, finest, getAnonymousLogger, getAnonymousLogger, getGlobal, getName, getResourceBundle, getResourceBundleName, info, log, log, logp, logp, logrb, logrb, logrb, logrb, setResourceBundle, severe, warning
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
loggerNode
The named logger tree node. -
LOGGER_CLASS_NAME
-
OFF_INT
static final int OFF_INT -
SEVERE_INT
static final int SEVERE_INT -
WARNING_INT
static final int WARNING_INT -
INFO_INT
static final int INFO_INT -
CONFIG_INT
static final int CONFIG_INT -
FINE_INT
static final int FINE_INT -
FINER_INT
static final int FINER_INT -
FINEST_INT
static final int FINEST_INT
-
-
Constructor Details
-
Logger
Logger(LoggerNode loggerNode, String name) Construct a new instance of an actual logger.- Parameters:
loggerNode- the node in the named logger treename- the fully-qualified name of this node
-
-
Method Details
-
getLogger
-
getLogger
-
writeReplace
- Throws:
ObjectStreamException
-
setFilter
- Overrides:
setFilterin classLogger- Throws:
SecurityException
-
getFilter
-
setLevel
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:
setLevelin classLogger- Throws:
SecurityException
-
setLevelName
Set the log level by name. Uses the parent logging context's name registry; otherwise behaves identically tosetLevel(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
-
isLoggable
- Overrides:
isLoggablein classLogger
-
getAttachment
Get the attachment value for a given key, ornullif there is no such attachment.- Type Parameters:
V- the attachment value type- Parameters:
key- the key- Returns:
- the attachment, or
nullif there is none for this key
-
attach
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 keyvalue- the attachment value- Returns:
- the old attachment, if there was one
- Throws:
SecurityException- if a security manager exists and if the caller does not haveLoggingPermission(control)
-
attachIfAbsent
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 keyvalue- the attachment value- Returns:
- the current attachment, if there is one, or
nullif the value was successfully attached - Throws:
SecurityException- if a security manager exists and if the caller does not haveLoggingPermission(control)
-
detach
Remove an attachment.- Type Parameters:
V- the attachment value type- Parameters:
key- the attachment key- Returns:
- the old value, or
nullif there was none - Throws:
SecurityException- if a security manager exists and if the caller does not haveLoggingPermission(control)
-
addHandler
- Overrides:
addHandlerin classLogger- Throws:
SecurityException
-
removeHandler
- Overrides:
removeHandlerin classLogger- Throws:
SecurityException
-
getHandlers
- Overrides:
getHandlersin classLogger
-
setHandlers
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 haveLoggingPermission(control)
-
getAndSetHandlers
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 haveLoggingPermission(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 handlersnewHandlers- the replacement list of handlers- Returns:
trueif the handler list was updated orfalseif the current handlers did not match the expected handlers list- Throws:
SecurityException- if a security manager exists and if the caller does not haveLoggingPermission(control)
-
clearHandlers
A convenience method to atomically get and clear all handlers.- Throws:
SecurityException- if a security manager exists and if the caller does not haveLoggingPermission(control)
-
setUseParentHandlers
public void setUseParentHandlers(boolean useParentHandlers) - Overrides:
setUseParentHandlersin classLogger
-
getUseParentHandlers
public boolean getUseParentHandlers()- Overrides:
getUseParentHandlersin classLogger
-
setUseParentFilters
public void setUseParentFilters(boolean useParentFilter) Specify whether or not filters should be inherited from parent loggers.Setting this value to
falsehas the same behaviour as Logger.- Parameters:
useParentFilter-trueto inherit a parents filter, otherwisefalse
-
getUseParentFilters
public boolean getUseParentFilters()Indicates whether or not this logger inherits filters from it's parent logger.- Returns:
trueif filters are inherited, otherwisefalse
-
getParent
-
setParent
Not allowed. This method may never be called.- Overrides:
setParentin classLogger- Throws:
SecurityException- always
-
getLogContext
Get the log context to which this logger belongs.- Returns:
- the log context
-
log
-
entering
-
entering
-
entering
-
exiting
-
exiting
-
throwing
-
severe
-
warning
-
info
-
config
-
fine
-
finer
-
finest
-
log
-
log
-
log
-
log
-
logp
-
logp
-
logp
-
logp
-
logrb
-
logrb
-
logrb
-
logrb
-
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 classlevel- the level to log atmessage- the messagebundleName- the resource bundle namestyle- the message format styleparams- the log parameterst- 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 classlevel- the level to log atmessage- the messagestyle- the message format styleparams- the log parameterst- the throwable, if any
-
log
-
logRaw
Do the logging with no level checks (they've already been done).- Parameters:
record- the extended log record
-
logRaw
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
-
finalize
-