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.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 class
Logger.AttachmentKey<V>
An attachment key instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addHandler(java.util.logging.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.java.util.logging.Handler[]
clearHandlers()
A convenience method to atomically get and clear all handlers.boolean
compareAndSetHandlers(java.util.logging.Handler[] expected, java.util.logging.Handler[] newHandlers)
Atomically compare and set the handler list for this logger.void
config(java.lang.String msg)
<V> V
detach(Logger.AttachmentKey<V> key)
Remove an attachment.void
entering(java.lang.String sourceClass, java.lang.String sourceMethod)
void
entering(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object param1)
void
entering(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object[] params)
void
exiting(java.lang.String sourceClass, java.lang.String sourceMethod)
void
exiting(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object result)
protected void
finalize()
void
fine(java.lang.String msg)
void
finer(java.lang.String msg)
void
finest(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> V
getAttachment(Logger.AttachmentKey<V> key)
Get the attachment value for a given key, ornull
if there is no such attachment.int
getEffectiveLevel()
Get the effective numerical log level, inherited from the parent.java.util.logging.Filter
getFilter()
java.util.logging.Handler[]
getHandlers()
java.util.logging.Level
getLevel()
LogContext
getLogContext()
Get the log context to which this logger belongs.static Logger
getLogger(java.lang.String name)
Static logger factory method which returns a JBoss LogManager logger.static Logger
getLogger(java.lang.String name, java.lang.String bundleName)
Static logger factory method which returns a JBoss LogManager logger.Logger
getParent()
boolean
getUseParentFilters()
Indicates whether or not this logger inherits filters from it's parent logger.boolean
getUseParentHandlers()
void
info(java.lang.String msg)
boolean
isLoggable(java.util.logging.Level level)
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.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.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.void
log(java.util.logging.Level level, java.lang.String msg)
void
log(java.util.logging.Level level, java.lang.String msg, java.lang.Object param1)
void
log(java.util.logging.Level level, java.lang.String msg, java.lang.Object[] params)
void
log(java.util.logging.Level level, java.lang.String msg, java.lang.Throwable thrown)
void
log(java.util.logging.LogRecord record)
void
logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
void
logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object param1)
void
logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object[] params)
void
logp(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Throwable thrown)
void
logRaw(java.util.logging.LogRecord record)
Do the logging with no level checks (they've already been done).void
logRaw(ExtLogRecord record)
Do the logging with no level checks (they've already been done).void
logrb(java.util.logging.Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg)
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)
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)
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)
void
removeHandler(java.util.logging.Handler handler)
void
setFilter(java.util.logging.Filter filter)
void
setHandlers(java.util.logging.Handler[] handlers)
A convenience method to atomically replace the handler list for this logger.void
setLevel(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).void
setLevelName(java.lang.String newLevelName)
Set the log level by name.void
setParent(java.util.logging.Logger parent)
Not allowed. This method may never be called.void
setUseParentFilters(boolean useParentFilter)
Specify whether or not filters should be inherited from parent loggers.void
setUseParentHandlers(boolean useParentHandlers)
void
severe(java.lang.String msg)
void
throwing(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Throwable thrown)
java.lang.String
toString()
void
warning(java.lang.String msg)
protected java.lang.Object
writeReplace()
-
-
-
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:
setFilter
in classjava.util.logging.Logger
- Throws:
java.lang.SecurityException
-
getFilter
public java.util.logging.Filter getFilter()
- Overrides:
getFilter
in classjava.util.logging.Logger
-
setLevel
public void setLevel(java.util.logging.Level newLevel) throws java.lang.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 classjava.util.logging.Logger
- Throws:
java.lang.SecurityException
-
setLevelName
public void setLevelName(java.lang.String newLevelName) throws java.lang.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:
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:
getLevel
in classjava.util.logging.Logger
-
isLoggable
public boolean isLoggable(java.util.logging.Level level)
- Overrides:
isLoggable
in classjava.util.logging.Logger
-
getAttachment
public <V> V getAttachment(Logger.AttachmentKey<V> key)
Get the attachment value for a given key, ornull
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 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
null
if 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
null
if 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:
addHandler
in classjava.util.logging.Logger
- Throws:
java.lang.SecurityException
-
removeHandler
public void removeHandler(java.util.logging.Handler handler) throws java.lang.SecurityException
- Overrides:
removeHandler
in classjava.util.logging.Logger
- Throws:
java.lang.SecurityException
-
getHandlers
public java.util.logging.Handler[] getHandlers()
- Overrides:
getHandlers
in classjava.util.logging.Logger
-
setHandlers
public void setHandlers(java.util.logging.Handler[] handlers) throws java.lang.SecurityException
A 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.SecurityException
Atomically 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.SecurityException
Atomically compare and set the handler list for this logger.- Parameters:
expected
- the expected list of handlersnewHandlers
- the replacement list of handlers- Returns:
true
if the handler list was updated orfalse
if 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.SecurityException
A 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:
setUseParentHandlers
in classjava.util.logging.Logger
-
getUseParentHandlers
public boolean getUseParentHandlers()
- Overrides:
getUseParentHandlers
in 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
false
has the same behaviour as Logger.- Parameters:
useParentFilter
-true
to inherit a parents filter, otherwisefalse
-
getUseParentFilters
public boolean getUseParentFilters()
Indicates whether or not this logger inherits filters from it's parent logger.- Returns:
true
if filters are inherited, otherwisefalse
-
getParent
public Logger getParent()
- Overrides:
getParent
in classjava.util.logging.Logger
-
setParent
public void setParent(java.util.logging.Logger parent)
Not allowed. This method may never be called.- Overrides:
setParent
in 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:
log
in classjava.util.logging.Logger
-
entering
public void entering(java.lang.String sourceClass, java.lang.String sourceMethod)
- Overrides:
entering
in classjava.util.logging.Logger
-
entering
public void entering(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object param1)
- Overrides:
entering
in classjava.util.logging.Logger
-
entering
public void entering(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object[] params)
- Overrides:
entering
in classjava.util.logging.Logger
-
exiting
public void exiting(java.lang.String sourceClass, java.lang.String sourceMethod)
- Overrides:
exiting
in classjava.util.logging.Logger
-
exiting
public void exiting(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object result)
- Overrides:
exiting
in classjava.util.logging.Logger
-
throwing
public void throwing(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Throwable thrown)
- Overrides:
throwing
in classjava.util.logging.Logger
-
severe
public void severe(java.lang.String msg)
- Overrides:
severe
in classjava.util.logging.Logger
-
warning
public void warning(java.lang.String msg)
- Overrides:
warning
in classjava.util.logging.Logger
-
info
public void info(java.lang.String msg)
- Overrides:
info
in classjava.util.logging.Logger
-
config
public void config(java.lang.String msg)
- Overrides:
config
in classjava.util.logging.Logger
-
fine
public void fine(java.lang.String msg)
- Overrides:
fine
in classjava.util.logging.Logger
-
finer
public void finer(java.lang.String msg)
- Overrides:
finer
in classjava.util.logging.Logger
-
finest
public void finest(java.lang.String msg)
- Overrides:
finest
in classjava.util.logging.Logger
-
log
public void log(java.util.logging.Level level, java.lang.String msg)
- Overrides:
log
in classjava.util.logging.Logger
-
log
public void log(java.util.logging.Level level, java.lang.String msg, java.lang.Object param1)
- Overrides:
log
in classjava.util.logging.Logger
-
log
public void log(java.util.logging.Level level, java.lang.String msg, java.lang.Object[] params)
- Overrides:
log
in classjava.util.logging.Logger
-
log
public void log(java.util.logging.Level level, java.lang.String msg, java.lang.Throwable thrown)
- Overrides:
log
in 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:
logp
in 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:
logp
in 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:
logp
in 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:
logp
in 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:
logrb
in 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:
logrb
in 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:
logrb
in 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:
logrb
in 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:
toString
in classjava.lang.Object
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
-