Package com.webmethods.caf.faces.util
Class LogUtils
java.lang.Object
com.webmethods.caf.faces.util.LogUtils
Utility functions for adding log messages to the Portal/MWS logs as category "JSF"or
to other external host logging mechanisms
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected 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
Retrieve the current FacesContext from this threadstatic Throwable
Extract the root cause of an exception chainstatic String
Convert the stack trace associated with the specified exception to Stringstatic boolean
isLogLevelEnabled
(int logLevel) Confirm if the logging level is enabled.static void
Log a message as text, using the specified log levelstatic void
Log a localized message from the default resource bundle using the specified log levelstatic void
Log an exception using the specified log levelstatic void
log
(int logLevel, FacesContext ctx, Class<?> bundleClass, String key) Log a localized message from the specified resource bundle using the specified log levelstatic void
Log a message as text, using the LEVEL_INFO log levelstatic void
Log an exception using the LEVEL_ERROR log levelstatic void
Log an exception using the LEVEL_ERROR log levelstatic void
log
(FacesContext ctx, Class<?> bundleClass, String key, Object[] args) Log a localized message from the specified resource bundle using the LEVEL_INFO log levelstatic 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 levelstatic 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 levelstatic 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 levelstatic void
logExternal
(String message) Log a string to the external host log handlerstatic void
logExternal
(String message, Throwable throwable) Log an exception to the the external host log handler
-
Field Details
-
LEVEL_OFF
public static final int LEVEL_OFF -
LEVEL_TRACE
public static final int LEVEL_TRACE- See Also:
-
LEVEL_DEBUG
public static final int LEVEL_DEBUG -
LEVEL_INFO
public static final int LEVEL_INFO -
LEVEL_WARN
public static final int LEVEL_WARN -
LEVEL_ERROR
public static final int LEVEL_ERROR -
LEVEL_FATAL
public static final int LEVEL_FATAL
-
-
Constructor Details
-
LogUtils
public LogUtils()
-
-
Method Details
-
getFacesContext
Retrieve the current FacesContext from this thread- Returns:
- Current FacesContext instance
-
logExternal
Log an exception to the the external host log handler- Parameters:
message
- Text message to logthrowable
- Throwable exception to log. The root cause exception and stacktrace will be included in the log message text.
-
logExternal
Log a string to the external host log handler- Parameters:
message
- Text message to log
-
getRootCause
Extract the root cause of an exception chain- Parameters:
throwable
- The base exception instance
-
isLogLevelEnabled
public static boolean isLogLevelEnabled(int logLevel) Confirm if the logging level is enabled.- Parameters:
logLevel
- Log level constant defined in LogUtils (e.g. LEVEL_DEBUG, LEVEL_WARN, etc..)- Returns:
- boolean - true if the requested level is enabled, false otherwise.
-
log
Log a message as text, using the specified log level- Parameters:
logLevel
- Log level constant defined in LogUtils (e.g. LEVEL_DEBUG, LEVEL_WARN, etc..)message
- The text message to record in the log
-
log
Log an exception using the specified log level- Parameters:
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.
-
log
Log an exception using the LEVEL_ERROR log level- Parameters:
throwable
- Throwable exception to log. The root cause exception and stacktrace will be included in the log message text.
-
log
Log an exception using the LEVEL_ERROR log level- Parameters:
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.
-
log
Log a message as text, using the LEVEL_INFO log level- Parameters:
message
- The text message to record in the log
-
log
Log a localized message from the default resource bundle using the specified log level- Parameters:
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 string
-
log
Log a localized message from the specified resource bundle using the specified log level- Parameters:
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 key
-
log
Log a localized message from the specified resource bundle using the LEVEL_INFO log level- Parameters:
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 string
-
log
public 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- Parameters:
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).
-
log
public 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- Parameters:
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.
-
log
public 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- Parameters:
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.
-
getStackTrace
Convert the stack trace associated with the specified exception to String- Parameters:
throwable
- Throwable exception to extract stack info from- Returns:
- The stack trace as a string (including carriage returns)
-
dumpComponentTreeToXMLFile
Output the provided UI component as XML content to a file .- Parameters:
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.
-
dumpComponent
Output the provided UI component as XML content to a print writer.- Parameters:
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. " "
-