Package org.jboss.logmanager
Class Logger
- java.lang.Object
-
- java.util.logging.Logger
-
- org.jboss.logmanager.Logger
-
- All Implemented Interfaces:
java.io.Serializable
public final class Logger extends java.util.logging.Logger implements java.io.SerializableAn 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddHandler(java.util.logging.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.java.util.logging.Handler[]clearHandlers()A convenience method to atomically get and clear all handlers.booleancompareAndSetHandlers(java.util.logging.Handler[] expected, java.util.logging.Handler[] newHandlers)Atomically compare and set the handler list for this logger.voidconfig(java.lang.String msg)<V> Vdetach(Logger.AttachmentKey<V> key)Remove an attachment.voidentering(java.lang.String sourceClass, java.lang.String sourceMethod)voidentering(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object param1)voidentering(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object[] params)voidexiting(java.lang.String sourceClass, java.lang.String sourceMethod)voidexiting(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object result)protected voidfinalize()voidfine(java.lang.String msg)voidfiner(java.lang.String msg)voidfinest(java.lang.String msg)java.util.logging.Handler[]getAndSetHandlers(java.util.logging.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.java.util.logging.FiltergetFilter()java.util.logging.Handler[]getHandlers()java.util.logging.LevelgetLevel()LogContextgetLogContext()Get the log context to which this logger belongs.static LoggergetLogger(java.lang.String name)Static logger factory method which returns a JBoss LogManager logger.static LoggergetLogger(java.lang.String name, java.lang.String bundleName)Static logger factory method which returns a JBoss LogManager logger.LoggergetParent()booleangetUseParentFilters()Indicates whether or not this logger inherits filters from it's parent logger.booleangetUseParentHandlers()voidinfo(java.lang.String msg)booleanisLoggable(java.util.logging.Level level)voidlog(java.lang.String fqcn, java.util.logging.Level level, java.lang.String message, java.lang.String bundleName, ExtLogRecord.FormatStyle style, java.lang.Object[] params, java.lang.Throwable t)SPI interface method to log a message at a given level, with a specific resource bundle.voidlog(java.lang.String fqcn, java.util.logging.Level level, java.lang.String message, java.lang.Throwable t)SPI interface method to log a message at a given level.voidlog(java.lang.String fqcn, java.util.logging.Level level, java.lang.String message, ExtLogRecord.FormatStyle style, java.lang.Object[] params, java.lang.Throwable t)SPI interface method to log a message at a given level.voidlog(java.util.logging.Level level, java.lang.String msg)voidlog(java.util.logging.Level level, java.lang.String msg, java.lang.Object param1)voidlog(java.util.logging.Level level, java.lang.String msg, java.lang.Object[] params)voidlog(java.util.logging.Level level, java.lang.String msg, java.lang.Throwable thrown)voidlog(java.util.logging.LogRecord record)voidlogp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)voidlogp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object param1)voidlogp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object[] params)voidlogp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Throwable thrown)voidlogRaw(java.util.logging.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(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg)voidlogrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg, java.lang.Object param1)voidlogrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg, java.lang.Object[] params)voidlogrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg, java.lang.Throwable thrown)voidremoveHandler(java.util.logging.Handler handler)voidsetFilter(java.util.logging.Filter filter)voidsetHandlers(java.util.logging.Handler[] handlers)A convenience method to atomically replace the handler list for this logger.voidsetLevel(java.util.logging.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(java.lang.String newLevelName)Set the log level by name.voidsetParent(java.util.logging.Logger parent)Not allowed. This method may never be called.voidsetUseParentFilters(boolean useParentFilter)Specify whether or not filters should be inherited from parent loggers.voidsetUseParentHandlers(boolean useParentHandlers)voidsevere(java.lang.String msg)voidthrowing(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Throwable thrown)java.lang.StringtoString()voidwarning(java.lang.String msg)protected java.lang.ObjectwriteReplace()
-
-
-
Method Detail
-
getLogger
public static Logger getLogger(java.lang.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(java.lang.String name, java.lang.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 java.lang.Object writeReplace() throws java.io.ObjectStreamException- Throws:
java.io.ObjectStreamException
-
setFilter
public void setFilter(java.util.logging.Filter filter) throws java.lang.SecurityException- Overrides:
setFilterin classjava.util.logging.Logger- Throws:
java.lang.SecurityException
-
getFilter
public java.util.logging.Filter getFilter()
- Overrides:
getFilterin classjava.util.logging.Logger
-
setLevel
public void setLevel(java.util.logging.Level newLevel) throws java.lang.SecurityExceptionThis 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 classjava.util.logging.Logger- Throws:
java.lang.SecurityException
-
setLevelName
public void setLevelName(java.lang.String newLevelName) throws java.lang.SecurityExceptionSet 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:
java.lang.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 java.util.logging.Level getLevel()
- Overrides:
getLevelin classjava.util.logging.Logger
-
isLoggable
public boolean isLoggable(java.util.logging.Level level)
- Overrides:
isLoggablein classjava.util.logging.Logger
-
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 java.lang.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:
java.lang.SecurityException- if a security manager exists and if the caller does not haveLoggingPermission(control)
-
attachIfAbsent
public <V> V attachIfAbsent(Logger.AttachmentKey<V> key, V value) throws java.lang.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:
java.lang.SecurityException- if a security manager exists and if the caller does not haveLoggingPermission(control)
-
detach
public <V> V detach(Logger.AttachmentKey<V> key) throws java.lang.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:
java.lang.SecurityException- if a security manager exists and if the caller does not haveLoggingPermission(control)
-
addHandler
public void addHandler(java.util.logging.Handler handler) throws java.lang.SecurityException- Overrides:
addHandlerin classjava.util.logging.Logger- Throws:
java.lang.SecurityException
-
removeHandler
public void removeHandler(java.util.logging.Handler handler) throws java.lang.SecurityException- Overrides:
removeHandlerin classjava.util.logging.Logger- Throws:
java.lang.SecurityException
-
getHandlers
public java.util.logging.Handler[] getHandlers()
- Overrides:
getHandlersin classjava.util.logging.Logger
-
setHandlers
public void setHandlers(java.util.logging.Handler[] handlers) throws java.lang.SecurityExceptionA convenience method to atomically replace the handler list for this logger.- Parameters:
handlers- the new handlers- Throws:
java.lang.SecurityException- if a security manager exists and if the caller does not haveLoggingPermission(control)
-
getAndSetHandlers
public java.util.logging.Handler[] getAndSetHandlers(java.util.logging.Handler[] handlers) throws java.lang.SecurityExceptionAtomically get and set the handler list for this logger.- Parameters:
handlers- the new handler set- Returns:
- the old handler set
- Throws:
java.lang.SecurityException- if a security manager exists and if the caller does not haveLoggingPermission(control)
-
compareAndSetHandlers
public boolean compareAndSetHandlers(java.util.logging.Handler[] expected, java.util.logging.Handler[] newHandlers) throws java.lang.SecurityExceptionAtomically 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:
java.lang.SecurityException- if a security manager exists and if the caller does not haveLoggingPermission(control)
-
clearHandlers
public java.util.logging.Handler[] clearHandlers() throws java.lang.SecurityExceptionA convenience method to atomically get and clear all handlers.- Throws:
java.lang.SecurityException- if a security manager exists and if the caller does not haveLoggingPermission(control)
-
setUseParentHandlers
public void setUseParentHandlers(boolean useParentHandlers)
- Overrides:
setUseParentHandlersin classjava.util.logging.Logger
-
getUseParentHandlers
public boolean getUseParentHandlers()
- Overrides:
getUseParentHandlersin classjava.util.logging.Logger
-
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
public Logger getParent()
- Overrides:
getParentin classjava.util.logging.Logger
-
setParent
public void setParent(java.util.logging.Logger parent)
Not allowed. This method may never be called.- Overrides:
setParentin classjava.util.logging.Logger- Throws:
java.lang.SecurityException- always
-
getLogContext
public LogContext getLogContext()
Get the log context to which this logger belongs.- Returns:
- the log context
-
log
public void log(java.util.logging.LogRecord record)
- Overrides:
login classjava.util.logging.Logger
-
entering
public void entering(java.lang.String sourceClass, java.lang.String sourceMethod)- Overrides:
enteringin classjava.util.logging.Logger
-
entering
public void entering(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object param1)- Overrides:
enteringin classjava.util.logging.Logger
-
entering
public void entering(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object[] params)- Overrides:
enteringin classjava.util.logging.Logger
-
exiting
public void exiting(java.lang.String sourceClass, java.lang.String sourceMethod)- Overrides:
exitingin classjava.util.logging.Logger
-
exiting
public void exiting(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object result)- Overrides:
exitingin classjava.util.logging.Logger
-
throwing
public void throwing(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Throwable thrown)- Overrides:
throwingin classjava.util.logging.Logger
-
severe
public void severe(java.lang.String msg)
- Overrides:
severein classjava.util.logging.Logger
-
warning
public void warning(java.lang.String msg)
- Overrides:
warningin classjava.util.logging.Logger
-
info
public void info(java.lang.String msg)
- Overrides:
infoin classjava.util.logging.Logger
-
config
public void config(java.lang.String msg)
- Overrides:
configin classjava.util.logging.Logger
-
fine
public void fine(java.lang.String msg)
- Overrides:
finein classjava.util.logging.Logger
-
finer
public void finer(java.lang.String msg)
- Overrides:
finerin classjava.util.logging.Logger
-
finest
public void finest(java.lang.String msg)
- Overrides:
finestin classjava.util.logging.Logger
-
log
public void log(java.util.logging.Level level, java.lang.String msg)- Overrides:
login classjava.util.logging.Logger
-
log
public void log(java.util.logging.Level level, java.lang.String msg, java.lang.Object param1)- Overrides:
login classjava.util.logging.Logger
-
log
public void log(java.util.logging.Level level, java.lang.String msg, java.lang.Object[] params)- Overrides:
login classjava.util.logging.Logger
-
log
public void log(java.util.logging.Level level, java.lang.String msg, java.lang.Throwable thrown)- Overrides:
login classjava.util.logging.Logger
-
logp
public void logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)- Overrides:
logpin classjava.util.logging.Logger
-
logp
public void logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object param1)- Overrides:
logpin classjava.util.logging.Logger
-
logp
public void logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object[] params)- Overrides:
logpin classjava.util.logging.Logger
-
logp
public void logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Throwable thrown)- Overrides:
logpin classjava.util.logging.Logger
-
logrb
public void logrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg)- Overrides:
logrbin classjava.util.logging.Logger
-
logrb
public void logrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg, java.lang.Object param1)- Overrides:
logrbin classjava.util.logging.Logger
-
logrb
public void logrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg, java.lang.Object[] params)- Overrides:
logrbin classjava.util.logging.Logger
-
logrb
public void logrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg, java.lang.Throwable thrown)- Overrides:
logrbin classjava.util.logging.Logger
-
log
public void log(java.lang.String fqcn, java.util.logging.Level level, java.lang.String message, java.lang.String bundleName, ExtLogRecord.FormatStyle style, java.lang.Object[] params, java.lang.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(java.lang.String fqcn, java.util.logging.Level level, java.lang.String message, ExtLogRecord.FormatStyle style, java.lang.Object[] params, java.lang.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(java.lang.String fqcn, java.util.logging.Level level, java.lang.String message, java.lang.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
-
logRaw
public void logRaw(java.util.logging.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 java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
-