public enum Log extends Enum<Log>
Sample usage:
private static final Logger log = Log.GENERAL.getLogger();
Enum Constant and Description |
---|
BOOTSTRAP
Bootstrap category.
|
CASS
Umbrella for Cassandra services.
|
CASS_CONN
Cassandra connection checker.
|
CASS_WAL
Umbrella for Cassandra Write Ahead Log.
|
CASS_WAL_GROUP
Cassandra WAL group operations.
|
CASS_WAL_LOG
Cassandra Write Ahead Log.
|
CASS_WAL_OSD
Cassandra object serialization/deserialization.
|
CASS_WAL_REPLAY
Cassandra Write Ahead Log Replay.
|
CID
CID category.
|
EJB_PROVIDER
EJB Provider category.
|
GENERAL
General category.
|
GUI
GUI category.
|
KEYSTONE
Keystone service.
|
NBIO
Network Buffered I/O.
|
NTG
Network Traffic Generator.
|
ROOT
Root of all loggers.
|
RS
REST API category.
|
SNMP
SNMP category.
|
Modifier and Type | Method and Description |
---|---|
org.slf4j.Logger |
getLogger()
Returns the logger associated with this enumeration constant.
|
String |
getName()
Returns the Logger path name.
|
static String |
stackTraceSnippet(Throwable t)
Returns a multi-line string consisting of the toString() of the given
throwable, followed by the top
SNIPPET_DEPTH frames of the
stack trace for the given throwable. |
static String |
stackTraceSnippet(Throwable t,
int maxDepth)
Returns a multi-line string consisting of the toString() of the given
throwable, followed by the top
maxDepth frames of the stack
trace for the given throwable. |
static Log |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static Log[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final Log ROOT
public static final Log GENERAL
public static final Log BOOTSTRAP
public static final Log NBIO
public static final Log RS
public static final Log GUI
public static final Log NTG
public static final Log CID
public static final Log EJB_PROVIDER
public static final Log SNMP
public static final Log KEYSTONE
public static final Log CASS
public static final Log CASS_CONN
public static final Log CASS_WAL
public static final Log CASS_WAL_OSD
public static final Log CASS_WAL_GROUP
public static final Log CASS_WAL_LOG
public static final Log CASS_WAL_REPLAY
public static Log[] values()
for (Log c : Log.values()) System.out.println(c);
public static Log valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic org.slf4j.Logger getLogger()
public String getName()
Do not use this for creating Loggers; use getLogger()
instead.
public static String stackTraceSnippet(Throwable t)
SNIPPET_DEPTH
frames of the
stack trace for the given throwable. To be used when logging exceptions.
If the throwable has a cause defined, that too will have the top few stack trace frames added to the output.
See stackTraceSnippet(Throwable, int)
for an example of usage.
t
- the throwablepublic static String stackTraceSnippet(Throwable t, int maxDepth)
maxDepth
frames of the stack
trace for the given throwable. To be used when logging exceptions.
An example of how this might be used:
private static final String MSG_BAD_CALLBACK = "Broken code? {} caused {}"; ... private void event(Event ev) { for (EventListener el: listeners) { try { el.event(ev); } catch (Exception e) { String who = el.getClass().getName(); log.warn(MSG_BAD_CALLBACK, who, Log.stackTraceSnippet(e, 3)); } } }This will result in a log message that might look something like this:
Aug 26, 2013 12:55:10 PM com.hp.util.LogTest snippet WARNING: Broken code? com.hp.foo.FooClass caused java.lang.RuntimeException: Test Exception com.hp.foo.FooClass.handleStuff(FooClass.java:65) com.hp.foo.FooClass.doEvent(FooClass.java:52) com.hp.bar.EventHandler.handleEvent(EventHandler.java:137) ...If the throwable has a cause defined, that too will have the top few stack trace frames added to the output.
t
- the throwablemaxDepth
- the maximum number of stack frames to includeCopyright © 2016. All Rights Reserved.