public class Logger extends Object
Facade to access IDE Logger methods.
Modifier and Type | Field and Description |
---|---|
private Class |
cl
Logger package (derived from class package).
|
(package private) static String |
EXCEPTIONS_FILE
Properties file containing exception messages.
|
private static Map<Package,Properties> |
excProps
Exception messages cache for individual packages.
|
private static char |
KEY_SEPARATOR
Message key elements separator.
|
private Logger |
logger
Logger instance. |
private static String |
LOGGER_NAME
GlassFish IDE SDK logger name.
|
private static Map<Package,Properties> |
logProps
Log messages cache for individual packages.
|
(package private) static String |
MESSAGES_FILE
Properties file containing log messages.
|
private String |
name
Logger name (derived from full class name including package).
|
(package private) static String |
PROPERTIES_FILE_SUFFIX
Properties file suffix.
|
Constructor and Description |
---|
Logger(Class c)
Creates an instance of library internal logger.
|
Modifier and Type | Method and Description |
---|---|
String |
buildKey(String method,
String key)
Builds message key as
<class_name>.<method_name>.<key> . |
private static String |
buildPropertiesFileName(String file,
boolean locales)
Build properties file name with suffix.
|
void |
exception(Level level,
String message)
Log an exception message as is.
|
static String |
excMsg(Class c,
String key)
Return message from exception messages properties file with given key.
|
String |
excMsg(String method,
String key)
Return message from exception messages properties file with given key.
|
static Logger |
getLogger()
Deprecated.
Instantiate Logger class!
|
boolean |
isLoggable(Level level)
Check if a message of the given level would actually be logged
by this logger.
|
static void |
log(Level level,
String msg,
Object param)
Deprecated.
Instantiate Logger class!
|
static void |
log(Level level,
String msg,
Object[] params)
Deprecated.
Instantiate Logger class!
|
void |
log(Level level,
String method,
String key)
Log a message, with no arguments from log messages catalog.
|
void |
log(Level level,
String method,
String key,
Object param)
Log a message with one object parameter from log messages catalog.
|
void |
log(Level level,
String method,
String key,
Object[] params)
Log a message with an array of object arguments
from log messages catalog.
|
void |
log(Level level,
String method,
String key,
Throwable thrown)
Log a message, with associated
Throwable information
from log messages catalog. |
static void |
log(Level level,
String msg,
Throwable thrown)
Deprecated.
Instantiate Logger class!
|
static boolean |
loggable(Level level)
Deprecated.
Instantiate Logger class!
|
static String |
logMsg(Class c,
String key)
Return message from log messages properties file with given key.
|
private static String |
message(String file,
Map<Package,Properties> propsMap,
Class c,
String key)
Return message from package to properties catalog map with given key.
|
private static final String LOGGER_NAME
static final String MESSAGES_FILE
static final String EXCEPTIONS_FILE
static final String PROPERTIES_FILE_SUFFIX
private static final char KEY_SEPARATOR
private static final Map<Package,Properties> logProps
private static final Map<Package,Properties> excProps
private final String name
private final Class cl
public Logger(Class c)
c
- Class where logger instance was created.public static Logger getLogger()
If a new logger is created its log level will be configured based on the LogManager configuration and it will configured to also send logging output to its parent's Handlers. It will be registered in the LogManager global name space.
public static boolean loggable(Level level)
level
- A message logging level.true
if the given message level is currently being
logged or false
otherwise.public static void log(Level level, String msg, Throwable thrown)
Throwable
information.
If the logger is currently enabled for the given message level then the given arguments are stored in a LogRecord which is forwarded to all registered output handlers.
Note that the thrown argument is stored in the LogRecord thrown property, rather than the LogRecord parameters property. Thus is it processed specially by output Formatters and is not treated as a formatting parameter to the LogRecord message property.
level
- One of the message level identifiers, e.g., SEVERE.msg
- The string message (or a key in the message catalog).thrown
- Throwable
associated with log message.public static void log(Level level, String msg, Object param)
If the logger is currently enabled for the given message level then a corresponding LogRecord is created and forwarded to all the registered output Handler objects.
level
- One of the message level identifiers, e.g. SEVERE.msg
- The string message (or a key in the message catalog).param
- Parameter to the message.public static void log(Level level, String msg, Object[] params)
If the logger is currently enabled for the given message level then a corresponding LogRecord is created and forwarded to all the registered output Handler objects.
level
- One of the message level identifiers, e.g. SEVERE.msg
- The string message (or a key in the message catalog).params
- Array of parameters to the message.private static String buildPropertiesFileName(String file, boolean locales)
file
- Messages catalog file name.locales
- Add locale suffix when true
or do not add it
when false
.private static String message(String file, Map<Package,Properties> propsMap, Class c, String key)
file
- Messages catalog file name.propsMap
- Package to properties catalog mapping.c
- Class to determine properties file package.key
- Exception message properties key.public static String logMsg(Class c, String key)
c
- Class to determine properties file package.key
- Exception message properties key.public static String excMsg(Class c, String key)
c
- Class to determine properties file package.key
- Exception message properties key.public String buildKey(String method, String key)
<class_name>.<method_name>.<key>
.
method
- The message string method key.key
- The message string key.public String excMsg(String method, String key)
method
- The message string method key.key
- The message string key.public boolean isLoggable(Level level)
level
- A message logging level.true
if the given message level is currently being
logged or false
otherwise.public void log(Level level, String method, String key)
If the logger is currently enabled for the given message level then the given message is forwarded to all the registered output Handler objects.
level
- One of the message level identifiers, e.g., SEVERE.msg
- The string message (or a key in the message catalog).public void log(Level level, String method, String key, Throwable thrown)
Throwable
information
from log messages catalog.
If the logger is currently enabled for the given message level then the given arguments are stored in a LogRecord which is forwarded to all registered output handlers.
Note that the thrown argument is stored in the LogRecord thrown property, rather than the LogRecord parameters property. Thus is it processed specially by output Formatters and is not treated as a formatting parameter to the LogRecord message property.
level
- One of the message level identifiers, e.g., SEVERE.method
- The message string method key.key
- The message string key.thrown
- Throwable
associated with log message.public void log(Level level, String method, String key, Object param)
If the logger is currently enabled for the given message level then a corresponding LogRecord is created and forwarded to all the registered output Handler objects.
level
- One of the message level identifiers, e.g. SEVERE.method
- The message string method key.key
- The message string key.param
- Parameter to the message.public void log(Level level, String method, String key, Object[] params)
If the logger is currently enabled for the given message level then a corresponding LogRecord is created and forwarded to all the registered output Handler objects.
level
- One of the message level identifiers, e.g. SEVERE.method
- The message string method key.key
- The message string key.params
- Array of parameters to the message.Copyright © 2013. All Rights Reserved.