public class LogUtils extends Object
Modifier and Type | Field and Description |
---|---|
static int |
LEVEL_DEBUG |
static int |
LEVEL_ERROR |
static int |
LEVEL_FATAL |
static int |
LEVEL_INFO |
static int |
LEVEL_OFF |
static int |
LEVEL_TRACE |
static int |
LEVEL_WARN |
Constructor and Description |
---|
LogUtils() |
Modifier and Type | Method and Description |
---|---|
protected static void |
dumpComponent(UIComponent rootComponent,
PrintWriter writer,
String indent)
Output the provided UI component as XML content to a print writer.
|
static void |
dumpComponentTreeToXMLFile(UIComponent rootComponent,
String outFileName)
Output the provided UI component as XML content to a file .
|
static FacesContext |
getFacesContext()
Retrieve the current FacesContext from this thread
|
static Throwable |
getRootCause(Throwable ex)
Extract the root cause of an exception chain
|
static String |
getStackTrace(Throwable t)
Convert the stack trace associated with the specified exception to String
|
static boolean |
isLogLevelEnabled(int logLevel)
Confirm if the logging level is enabled.
|
static void |
log(FacesContext ctx,
Class<?> bundleClass,
String key,
Object[] args)
Log a localized message from the specified resource bundle using the LEVEL_INFO log level
|
static void |
log(FacesContext ctx,
Class<?> bundleClass,
String key,
Object[] args,
boolean prependKey,
Throwable t)
Log a localized message from the specified resource bundle using the LEVEL_INFO log level
|
static void |
log(FacesContext ctx,
String bundleName,
String key,
Object[] args,
boolean prependKey)
Log a localized message from the specified resource bundle using the LEVEL_INFO log level
|
static void |
log(FacesContext ctx,
String bundleName,
String key,
Object[] args,
boolean prependKey,
Throwable t)
Log a localized message from the specified resource bundle using the LEVEL_INFO log level
|
static void |
log(int logLevel,
FacesContext ctx,
Class<?> bundleClass,
String key)
Log a localized message from the specified resource bundle using the specified log level
|
static void |
log(int logLevel,
String message)
Log a message as text, using the specified log level
|
static void |
log(int logLevel,
String key,
Object[] args)
Log a localized message from the default resource bundle using the specified log level
|
static void |
log(int logLevel,
String message,
Throwable t)
Log an exception using the specified log level
|
static void |
log(String message)
Log a message as text, using the LEVEL_INFO log level
|
static void |
log(String message,
Throwable throwable)
Log an exception using the LEVEL_ERROR log level
|
static void |
log(Throwable throwable)
Log an exception using the LEVEL_ERROR log level
|
static void |
logExternal(String message)
Log a string to the external host log handler
|
static void |
logExternal(String message,
Throwable throwable)
Log an exception to the the external host log handler
|
public static final int LEVEL_OFF
public static final int LEVEL_TRACE
public static final int LEVEL_DEBUG
public static final int LEVEL_INFO
public static final int LEVEL_WARN
public static final int LEVEL_ERROR
public static final int LEVEL_FATAL
public static FacesContext getFacesContext()
public static void logExternal(String message, Throwable throwable)
message
- Text message to logthrowable
- Throwable exception to log. The root cause exception and stacktrace
will be included in the log message text.public static void logExternal(String message)
message
- Text message to logpublic static Throwable getRootCause(Throwable ex)
throwable
- The base exception instancepublic static boolean isLogLevelEnabled(int logLevel)
logLevel
- Log level constant defined in LogUtils (e.g. LEVEL_DEBUG, LEVEL_WARN, etc..)public static void log(int logLevel, String message)
logLevel
- Log level constant defined in LogUtils (e.g. LEVEL_DEBUG, LEVEL_WARN, etc..)message
- The text message to record in the logpublic static void log(int logLevel, String message, Throwable t)
logLevel
- Log level constant defined in LogUtils (e.g. LEVEL_DEBUG, LEVEL_WARN, etc..)message
- The text message to record in the logthrowable
- Throwable exception to log. The root cause exception and stacktrace
will be included in the log message text.public static void log(Throwable throwable)
throwable
- Throwable exception to log. The root cause exception and stacktrace
will be included in the log message text.public static void log(String message, Throwable throwable)
message
- The text message to record in the logthrowable
- Throwable exception to log. The root cause exception and stacktrace
will be included in the log message text.public static void log(String message)
message
- The text message to record in the logpublic static void log(int logLevel, String key, Object[] args)
logLevel
- Log level constant defined in LogUtils (e.g. LEVEL_DEBUG, LEVEL_WARN, etc..)key
- Resource bundle lookup keyargs
- String substitution arguments for the return resource bundle stringpublic static void log(int logLevel, FacesContext ctx, Class<?> bundleClass, String key)
logLevel
- Log level constant defined in LogUtils (e.g. LEVEL_DEBUG, LEVEL_WARN, etc..)ctx
- FacesContext instance to use to determine message localebundleClass
- Class of the resource bundlekey
- Resource bundle lookup keypublic static void log(FacesContext ctx, Class<?> bundleClass, String key, Object[] args)
ctx
- FacesContext instance to use to determine message localebundleClass
- Class of the resource bundlekey
- Resource bundle lookup keyargs
- String substitution arguments for the return resource bundle stringpublic static void log(FacesContext ctx, String bundleName, String key, Object[] args, boolean prependKey)
ctx
- FacesContext instance to use to determine message localebundleName
- Resource bundle class name as Stringkey
- Resource bundle lookup keyargs
- String substitution arguments for the return resource bundle stringprependKey
- True to prepend the key to formatted message (for an error message).public static void log(FacesContext ctx, String bundleName, String key, Object[] args, boolean prependKey, Throwable t)
ctx
- FacesContext instance to use to determine message localebundleName
- Resource bundle class name as Stringkey
- Resource bundle lookup keyargs
- String substitution arguments for the return resource bundle stringprependKey
- True to prepend the key to formatted message (for an error message).throwable
- Throwable exception to log. The root cause exception and stacktrace
will be included in the log message text.public static void log(FacesContext ctx, Class<?> bundleClass, String key, Object[] args, boolean prependKey, Throwable t)
ctx
- FacesContext instance to use to determine message localebundleClass
- Resource bundle Classkey
- Resource bundle lookup keyargs
- String substitution arguments for the return resource bundle stringprependKey
- True to prepend the key to formatted message (for an error message).throwable
- Throwable exception to log. The root cause exception and stacktrace
will be included in the log message text.public static String getStackTrace(Throwable t)
throwable
- Throwable exception to extract stack info frompublic static void dumpComponentTreeToXMLFile(UIComponent rootComponent, String outFileName)
rootComponent
- The UI component to write out to the file.outFileName
- The name of the file to use as the destination of this writer.
If the file exists then it will be truncated to zero size; otherwise, a new file will be created.
The output will be written to the file and is buffered.protected static void dumpComponent(UIComponent rootComponent, PrintWriter writer, String indent)
rootComponent
- The UI component to write out to the file.writer
- The print writer to output the UI component.indent
- Indent in spaces for the entire content. IE. " "