- java.lang.Object
-
- java.util.logging.Logger
-
- 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
Nested Classes Modifier and Type Class Description static classLogger.AttachmentKey<V>An attachment key instance.
-
Field Summary
-
Fields inherited from class java.util.logging.Logger
global, GLOBAL_LOGGER_NAME
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddHandler(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[]clearHandlers()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.voidconfig(String msg)voidconfig(Supplier<String> msgSupplier)<V> Vdetach(Logger.AttachmentKey<V> key)Remove an attachment.voidentering(String sourceClass, String sourceMethod)voidentering(String sourceClass, String sourceMethod, Object param1)voidentering(String sourceClass, String sourceMethod, Object[] params)voidexiting(String sourceClass, String sourceMethod)voidexiting(String sourceClass, String sourceMethod, Object result)voidfine(String msg)voidfine(Supplier<String> msgSupplier)voidfiner(String msg)voidfiner(Supplier<String> msgSupplier)voidfinest(String msg)voidfinest(Supplier<String> msgSupplier)Handler[]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.intgetEffectiveLevel()Get the effective numerical log level, inherited from the parent.FiltergetFilter()Handler[]getHandlers()LevelgetLevel()LogContextgetLogContext()Get the log context to which this logger belongs.static LoggergetLogger(String name)Static logger factory method which returns a JBoss LogManager logger.static LoggergetLogger(String name, String bundleName)Static logger factory method which returns a JBoss LogManager logger.LoggergetParent()ResourceBundlegetResourceBundle()Get the resource bundle for this logger.booleangetUseParentFilters()Indicates whether or not this logger inherits filters from it's parent logger.booleangetUseParentHandlers()voidinfo(String msg)voidinfo(Supplier<String> msgSupplier)booleanisLoggable(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.voidlog(String fqcn, Level level, String message, Throwable t)SPI 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.voidlog(Level level, String msg)voidlog(Level level, String msg, Object param1)voidlog(Level level, String msg, Object[] params)voidlog(Level level, String msg, Throwable thrown)voidlog(Level level, Throwable thrown, Supplier<String> msgSupplier)voidlog(Level level, Supplier<String> msgSupplier)voidlog(LogRecord record)voidlogp(Level level, String sourceClass, String sourceMethod, String msg)voidlogp(Level level, String sourceClass, String sourceMethod, String msg, Object param1)voidlogp(Level level, String sourceClass, String sourceMethod, String msg, Object[] params)voidlogp(Level level, String sourceClass, String sourceMethod, String msg, Throwable thrown)voidlogp(Level level, String sourceClass, String sourceMethod, Throwable thrown, Supplier<String> msgSupplier)voidlogp(Level level, String sourceClass, String sourceMethod, Supplier<String> msgSupplier)voidlogRaw(LogRecord record)Do 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).voidlogrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msg)Deprecated, for removal: This API element is subject to removal in a future version.voidlogrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msg, Object param1)Deprecated, for removal: This API element is subject to removal in a future version.voidlogrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msg, Object[] params)Deprecated, for removal: This API element is subject to removal in a future version.voidlogrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msg, Throwable thrown)Deprecated, for removal: This API element is subject to removal in a future version.voidlogrb(Level level, String sourceClass, String sourceMethod, ResourceBundle bundle, String msg, Object... params)voidlogrb(Level level, String sourceClass, String sourceMethod, ResourceBundle bundle, String msg, Throwable thrown)voidlogrb(Level level, ResourceBundle bundle, String msg, Object... params)voidlogrb(Level level, ResourceBundle bundle, String msg, Throwable thrown)voidremoveHandler(Handler handler)voidsetFilter(Filter filter)voidsetHandlers(Handler[] handlers)A convenience method to atomically replace the handler list for this logger.voidsetLevel(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).voidsetLevelName(String newLevelName)Set the log level by name.voidsetParent(Logger parent)Not allowed. This method may never be called.voidsetResourceBundle(ResourceBundle resourceBundle)Set the resource bundle for this logger.voidsetUseParentFilters(boolean useParentFilter)Specify whether or not filters should be inherited from parent loggers.voidsetUseParentHandlers(boolean useParentHandlers)voidsevere(String msg)voidsevere(Supplier<String> msgSupplier)voidthrowing(String sourceClass, String sourceMethod, Throwable thrown)StringtoString()voidwarning(String msg)voidwarning(Supplier<String> msgSupplier)protected ObjectwriteReplace()-
Methods inherited from class java.util.logging.Logger
getAnonymousLogger, getAnonymousLogger, getGlobal, getName, getResourceBundleName
-
-
-
-
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 namebundleName- the bundle name- Returns:
- the logger
-
writeReplace
protected final Object writeReplace() throws ObjectStreamException
- Throws:
ObjectStreamException
-
setFilter
public void setFilter(Filter filter) throws SecurityException
- Overrides:
setFilterin classLogger- Throws:
SecurityException
-
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:
setLevelin classLogger- 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 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
-
isLoggable
public boolean isLoggable(Level level)
- Overrides:
isLoggablein classLogger
-
getAttachment
public <V> V getAttachment(Logger.AttachmentKey<V> key)
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
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 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)IllegalArgumentException- if the attachment cannot be added because the maximum has been reached
-
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 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)IllegalArgumentException- if the attachment cannot be added because the maximum has been reached
-
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
nullif there was none - Throws:
SecurityException- if a security manager exists and if the caller does not haveLoggingPermission(control)
-
addHandler
public void addHandler(Handler handler) throws SecurityException
- Overrides:
addHandlerin classLogger- Throws:
SecurityException
-
removeHandler
public void removeHandler(Handler handler) throws SecurityException
- Overrides:
removeHandlerin classLogger- Throws:
SecurityException
-
getHandlers
public Handler[] getHandlers()
- Overrides:
getHandlersin classLogger
-
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 haveLoggingPermission(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 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
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 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
-
setParent
public void setParent(Logger parent)
Not allowed. This method may never be called.- Overrides:
setParentin classLogger- Throws:
SecurityException- always
-
getLogContext
public LogContext getLogContext()
Get the log context to which this logger belongs.- Returns:
- the log context
-
logp
public void logp(Level level, String sourceClass, String sourceMethod, Supplier<String> msgSupplier)
-
logp
public void logp(Level level, String sourceClass, String sourceMethod, String msg, Object param1)
-
logp
public void logp(Level level, String sourceClass, String sourceMethod, String msg, Object[] params)
-
logp
public void logp(Level level, String sourceClass, String sourceMethod, String msg, Throwable thrown)
-
logp
public void logp(Level level, String sourceClass, String sourceMethod, Throwable thrown, Supplier<String> msgSupplier)
-
logrb
@Deprecated(since="3.0", forRemoval=true) public void logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msg)
Deprecated, for removal: This API element is subject to removal in a future version.
-
logrb
@Deprecated(since="3.0", forRemoval=true) public void logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msg, Object param1)
Deprecated, for removal: This API element is subject to removal in a future version.
-
logrb
@Deprecated(since="3.0", forRemoval=true) public void logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msg, Object[] params)
Deprecated, for removal: This API element is subject to removal in a future version.
-
logrb
@Deprecated(since="3.0", forRemoval=true) public void logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msg, Throwable thrown)
Deprecated, for removal: This API element is subject to removal in a future version.
-
logrb
public void logrb(Level level, String sourceClass, String sourceMethod, ResourceBundle bundle, String msg, Object... params)
-
logrb
public void logrb(Level level, ResourceBundle bundle, String msg, Object... params)
-
logrb
public void logrb(Level level, String sourceClass, String sourceMethod, ResourceBundle bundle, String msg, Throwable thrown)
-
logrb
public void logrb(Level level, ResourceBundle bundle, String msg, Throwable thrown)
-
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
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 classlevel- the level to log atmessage- the messaget- 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
-
setResourceBundle
public void setResourceBundle(ResourceBundle resourceBundle)
Set the resource bundle for this logger.- Overrides:
setResourceBundlein classLogger- Parameters:
resourceBundle- the resource bundle (must not benull)
-
getResourceBundle
public ResourceBundle getResourceBundle()
Get the resource bundle for this logger.- Overrides:
getResourceBundlein classLogger- Returns:
- the resource bundle, or
nullif none is configured for this logger
-
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
-
-