|
Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client 11g Release 1 (11.1.1) E17503-02 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectoracle.adfnmc.java.util.logging.Logger
public class Logger
Loggers are used to log records to certain outputs, including file, console, etc. They use various handlers to actually do the output-dependent operations.
Client applications can get named loggers by calling the methods
getLogger
. They can also get anonymous loggers by calling the
methods getAnonymousLogger
. Named loggers are organized in a
namespace hierarchy managed by a log manager. The naming convention is
usually the same as java package's naming convention, i.e., using
dot-separated strings. Anonymous loggers do not belong to any namespace.
Loggers "inherit" log level setting from their parent if its own level is set
to null
. This is also true for the resource bundle. The
logger's resource bundle is used to localize the log messages if no resource
bundle name is given when a log method is called. If
getUseParentHandlers
is true
, loggers also
inherit their parent's handlers. Here "inherit" only means the "behaviors"
are inherited. The internal fields value will not change, for example,
getLevel()
still returns null
.
When loading a given resource bundle, the logger first tries to use the context classloader. If that fails, it tries the system classloader. And if that still fails, it searches up the class stack and uses each class's classloader to try to locate the resource bundle.
Some log methods accept log requests that do not specify the source class and source method. In these cases, the logging framework will automatically infer the calling class and method, but not guaranteed to be accurate.
Once a LogRecord
object has been passed into the logging
framework, it is owned by the logging framework and the client applications
should not use it any longer.
All methods of this class are thread-safe.
LogManager
Field Summary | |
---|---|
static Logger |
global
The global logger is provided as convenience for casual use. |
Constructor Summary | |
---|---|
protected |
Logger(java.lang.String name,
java.lang.String resourceBundleName)
Constructs a Logger object with the supplied name and
resource bundle name. |
Method Summary | |
---|---|
void |
addHandler(Handler handler)
Adds a handler to this logger. |
void |
config(java.lang.String msg)
Logs a message of level Level.CONFIG . |
void |
entering(java.lang.String sourceClass,
java.lang.String sourceMethod)
Logs a message indicating entering a method. |
void |
entering(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.Object param)
Logs a message indicating entering a method. |
void |
entering(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.Object[] params)
Logs a message indicating entering a method. |
void |
exiting(java.lang.String sourceClass,
java.lang.String sourceMethod)
Logs a message indicating existing a method. |
void |
exiting(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.Object result)
Logs a message indicating exiting a method. |
void |
fine(java.lang.String msg)
Logs a message of level Level.FINE . |
void |
finer(java.lang.String msg)
Logs a message of level Level.FINER . |
void |
finest(java.lang.String msg)
Logs a message of level Level.FINEST . |
static Logger |
getAnonymousLogger()
Gets an anonymous logger to use internally in a thread. |
static Logger |
getAnonymousLogger(java.lang.String resourceBundleName)
Gets an anonymous logger to use internally in a thread. |
Filter |
getFilter()
Gets the filter used by this logger. |
List |
getHandlers()
Gets all the handlers associated with this logger. |
Level |
getLevel()
Gets the logging level of this logger. |
static Logger |
getLogger(java.lang.String name)
Gets a named logger. |
static Logger |
getLogger(java.lang.String name,
java.lang.String resourceBundleName)
Gets a named logger associated with the supplied resource bundle. |
java.lang.String |
getName()
Gets the name of this logger. |
Logger |
getParent()
Gets the parent of this logger in the namespace. |
boolean |
getUseParentHandlers()
Gets the flag which indicates whether to use parent's handlers to publish incoming log records, potentially recursively up the namespace. |
void |
info(java.lang.String msg)
Logs a message of level Level.INFO . |
boolean |
isLevelLoggable(Level l)
This method is for compatibility. |
boolean |
isLoggable(Level l)
Determines whether this logger will actually log messages of the specified level. |
void |
log(Level logLevel,
java.lang.String msg)
Logs a message of the specified level. |
void |
log(Level logLevel,
java.lang.String msg,
java.lang.Object param)
Logs a message of the specified level with the supplied parameter. |
void |
log(Level logLevel,
java.lang.String msg,
java.lang.Object[] params)
Logs a message of the specified level with the supplied parameter array. |
void |
log(Level logLevel,
java.lang.String msg,
java.lang.Throwable thrown)
Logs a message of the specified level with the supplied Throwable object. |
void |
log(LogRecord record)
Logs a given log record. |
void |
logp(Level logLevel,
java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg)
Logs a message of the given level with the specified source class name and source method name. |
void |
logp(Level logLevel,
java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg,
java.lang.Object param)
Logs a message of the given level with the specified source class name and source method name and parameter. |
void |
logp(Level logLevel,
java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg,
java.lang.Object[] params)
Logs a message of the given level with the specified source class name and source method name and parameter array. |
void |
logp(Level logLevel,
java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String msg,
java.lang.Throwable thrown)
Logs a message of the given level with the specified source class name and source method name and Throwable object. |
void |
logrb(Level logLevel,
java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String bundleName,
java.lang.String msg)
Logs a message of the given level with the specified source class name and source method name, using the given resource bundle to localize the message. |
void |
logrb(Level logLevel,
java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String bundleName,
java.lang.String msg,
java.lang.Object param)
Logs a message of the given level with the specified source class name and source method name and parameter, using the given resource bundle to localize the message. |
void |
logrb(Level logLevel,
java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String bundleName,
java.lang.String msg,
java.lang.Object[] params)
Logs a message of the given level with the specified source class name and source method name and parameter array, using the given resource bundle to localize the message. |
void |
logrb(Level logLevel,
java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.String bundleName,
java.lang.String msg,
java.lang.Throwable thrown)
Logs a message of the given level with the specified source class name and source method name and Throwable object, using the
given resource bundle to localize the message. |
void |
removeHandler(Handler handler)
Removes a handler for this logger. |
void |
setFilter(Filter newFilter)
Sets the filter used by this logger. |
void |
setLevel(Level newLevel)
Sets the logging level for this logger. |
void |
setParent(Logger parent)
Sets the parent of this logger in the namespace. |
void |
setUseParentHandlers(boolean notifyParentHandlers)
Sets the flag which indicates whether to use parent's handlers to publish incoming log records, potentially recursively up the namespace. |
void |
severe(java.lang.String msg)
Logs a message of level Level.SEVERE . |
void |
throwing(java.lang.String sourceClass,
java.lang.String sourceMethod,
java.lang.Throwable thrown)
Logs a message indicating throwing an exception. |
void |
warning(java.lang.String msg)
Logs a message of level Level.WARNING . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Logger global
Constructor Detail |
---|
protected Logger(java.lang.String name, java.lang.String resourceBundleName)
Logger
object with the supplied name and
resource bundle name.
name
- the name of this logger, may be null for anonymous loggersresourceBundleName
- the name of the resource bundle used to localize logging
messages, may be null
MissingResourceException
- If the specified resource bundle can not be loaded.Method Detail |
---|
public static Logger getAnonymousLogger()
Anonymous loggers' parent is set to be the root logger. This enables them to inherit default logging level and handlers from the root logger.
public static Logger getAnonymousLogger(java.lang.String resourceBundleName)
Anonymous loggers' parent is set to be the root logger. This enables them to inherit default logging level and handlers from the root logger.
resourceBundleName
- the name of the resource bundle used to localize log messages
MissingResourceException
- If the specified resource bundle can not be loaded.public static Logger getLogger(java.lang.String name)
LogManager
's properties if any.
name
- the name of the logger to get, cannot be null
MissingResourceException
- If the specified resource bundle can not be loaded.public static Logger getLogger(java.lang.String name, java.lang.String resourceBundleName)
name
- the name of the logger to get, cannot be nullresourceBundleName
- the name of the resource bundle, may be null
public void addHandler(Handler handler)
handler
- the handler object to add, cannot be null
java.lang.SecurityException
- If a security manager determines that the caller does not
have the required permission.public List getHandlers()
public void removeHandler(Handler handler)
handler
- the handler to be removed, cannot be null
java.lang.SecurityException
- If a security manager determines that the caller does not
have the required permission.public Filter getFilter()
public void setFilter(Filter newFilter)
newFilter
- the filter to set
java.lang.SecurityException
- If a security manager determines that the caller does not
have the required permission.public Level getLevel()
public void setLevel(Level newLevel)
null
level
indicates this logger will inherit its parent's level.
newLevel
- the logging level to set
java.lang.SecurityException
- If a security manager determines that the caller does not
have the required permission.public boolean getUseParentHandlers()
true
if set to use parent's handlers, otherwise
false
public void setUseParentHandlers(boolean notifyParentHandlers)
notifyParentHandlers
- the flag whether to use parent's handlers
java.lang.SecurityException
- If a security manager determines that the caller does not
have the required permission.public Logger getParent()
public void setParent(Logger parent)
LogManager
object only.
parent
- the parent logger to set
java.lang.SecurityException
- If a security manager determines that the caller does not
have the required permission.public java.lang.String getName()
public final boolean isLevelLoggable(Level l)
public boolean isLoggable(Level l)
Level.INFO
.
l
- the level to check
true
if this logger will actually log this level,
otherwise false
public void entering(java.lang.String sourceClass, java.lang.String sourceMethod)
Level.FINER
, log message "ENTRY", and the specified
source class name and source method name is submitted for logging.
sourceClass
- the calling class namesourceMethod
- the method namepublic void entering(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object param)
Level.FINER
, log message "ENTRY", and the specified
source class name and source method name and one parameter is submitted
for logging.
sourceClass
- the source class namesourceMethod
- the source method nameparam
- the parameter for the method callpublic void entering(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object[] params)
Level.FINER
, log message "ENTRY", and the specified
source class name and source method name and parameters is submitted for
logging.
sourceClass
- the source class namesourceMethod
- the source method nameparams
- an array of parameters for the method callpublic void exiting(java.lang.String sourceClass, java.lang.String sourceMethod)
Level.FINER
, log message "RETURN", and the specified
source class name and source method name is submitted for logging.
sourceClass
- the calling class namesourceMethod
- the method namepublic void exiting(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object result)
Level.FINER
, log message "RETURN", and the specified
source class name and source method name and return value is submitted
for logging.
sourceClass
- the source class namesourceMethod
- the source method nameresult
- the return value of the method callpublic void throwing(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Throwable thrown)
Level.FINER
, log message "THROW", and the specified
source class name and source method name and Throwable
object is submitted for logging.
sourceClass
- the source class namesourceMethod
- the source method namethrown
- the Throwable
objectpublic void severe(java.lang.String msg)
Level.SEVERE
.
msg
- the message to logpublic void warning(java.lang.String msg)
Level.WARNING
.
msg
- the message to logpublic void info(java.lang.String msg)
Level.INFO
.
msg
- the message to logpublic void config(java.lang.String msg)
Level.CONFIG
.
msg
- the message to logpublic void fine(java.lang.String msg)
Level.FINE
.
msg
- the message to logpublic void finer(java.lang.String msg)
Level.FINER
.
msg
- the message to logpublic void finest(java.lang.String msg)
Level.FINEST
.
msg
- the message to logpublic void log(Level logLevel, java.lang.String msg)
logLevel
- the level of the given messagemsg
- the message to logpublic void log(Level logLevel, java.lang.String msg, java.lang.Object param)
logLevel
- the level of the given messagemsg
- the message to logparam
- the parameter associated with the event that need to be loggedpublic void log(Level logLevel, java.lang.String msg, java.lang.Object[] params)
logLevel
- the level of the given messagemsg
- the message to logparams
- the parameter array associated with the event that need to be
loggedpublic void log(Level logLevel, java.lang.String msg, java.lang.Throwable thrown)
Throwable
object.
logLevel
- the level of the given messagemsg
- the message to logthrown
- the Throwable
object associated with the event
that need to be loggedpublic void log(LogRecord record)
getUseParentHandlers()
is true
,
the log record will also be submitted to the parent logger's handlers,
potentially recursively up the namespace.
Since all other log methods call this method to actually perform the logging action, subclasses of this class can override this method to catch all logging activities.
record
- the log record to be loggedpublic void logp(Level logLevel, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
logLevel
- the level of the given messagesourceClass
- the source class namesourceMethod
- the source method namemsg
- the message to be loggedpublic void logp(Level logLevel, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object param)
logLevel
- the level of the given messagesourceClass
- the source class namesourceMethod
- the source method namemsg
- the message to be loggedparam
- the parameter associated with the event that need to be loggedpublic void logp(Level logLevel, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object[] params)
logLevel
- the level of the given messagesourceClass
- the source class namesourceMethod
- the source method namemsg
- the message to be loggedparams
- the parameter array associated with the event that need to be
loggedpublic void logp(Level logLevel, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Throwable thrown)
Throwable
object.
logLevel
- the level of the given messagesourceClass
- the source class namesourceMethod
- the source method namemsg
- the message to be loggedthrown
- the Throwable
objectpublic void logrb(Level logLevel, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg)
logLevel
- the level of the given messagesourceClass
- the source class namesourceMethod
- the source method namebundleName
- the name of the resource bundle, used to localize the messagemsg
- the message to be loggedpublic void logrb(Level logLevel, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg, java.lang.Object param)
logLevel
- the level of the given messagesourceClass
- the source class namesourceMethod
- the source method namebundleName
- the name of the resource bundle, used to localize the messagemsg
- the message to be loggedparam
- the parameter associated with the event that need to be loggedpublic void logrb(Level logLevel, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg, java.lang.Object[] params)
logLevel
- the level of the given messagesourceClass
- the source class namesourceMethod
- the source method namebundleName
- the name of the resource bundle, used to localize the messagemsg
- the message to be loggedparams
- the parameter array associated with the event that need to be
loggedpublic void logrb(Level logLevel, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg, java.lang.Throwable thrown)
Throwable
object, using the
given resource bundle to localize the message.
logLevel
- the level of the given messagesourceClass
- the source class namesourceMethod
- the source method namebundleName
- the name of the resource bundle, used to localize the messagemsg
- the message to be loggedthrown
- the Throwable
object
|
Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client 11g Release 1 (11.1.1) E17503-02 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |