Class Debug
Allows a uniform interface to file debug and exception information in a
uniform format. Debug supports different levels/states of
filing debug information (in the ascending order): OFF,
ERROR, WARNING, MESSAGE and
ON. A given debug level/state is enabled if the debug
state/level is set to at least that state/level. For example, if the debug
state is ERROR, only errors will be filed. If the debug state
is WARNING, only errors and warnings will be filed. If the
debug state is MESSAGE, everything will be filed.
MESSAGE and ON are of the same levels; the
difference between them being MESSAGE writes to a file,
whereas ON writes to System.out.
Debug service uses the property file, AMConfig.properties, to
set the default debug level and the output directory where the debug files
will be placed. The properties file is located (using
ResourceBundle semantics) from one of the directories in
the CLASSPATH.
The following keys are used to configure the Debug service. Possible values for the key 'com.iplanet.services.debug.level' are: off | error | warning | message. The key 'com.iplanet.services.debug.directory' specifies the output directory where the debug files will be created. Optionally, the key 'com.sun.identity.util.debug.provider' may be used to plugin a non-default implementation of the debug service where necessary.
If there is an error reading or loading the properties, Debug service will redirect all debug information tocom.iplanet.services.debug.level com.iplanet.services.debug.directory com.sun.identity.util.debug.provider
System.out
If these properties are changed, the server must be restarted for the changes
to take effect.
NOTE: Debugging is an IO intensive operation and may hurt application
performance when abused. Particularly, note that Java evaluates the arguments
to message() and warning() even when debugging
is turned off. It is recommended that the debug state be checked before
invoking any message() or warning() methods to
avoid unnecessary argument evaluation and to maximize application
performance.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDeprecated.flags the state where error debugging is enabled.static final intDeprecated.This state enables debugging of messages, warnings and errors.static final intDeprecated.flags the disabled debug state.static final intDeprecated.flags the enabled debug state for warnings, errors and messages.static final StringDeprecated.flags the state where error debugging is enabled.static final StringDeprecated.This state enables debugging of messages, warnings and errors.static final StringDeprecated.flags the disabled debug state.static final StringDeprecated.flags the enables debug state for warnings, errors and messages.static final StringDeprecated.flags the state where warning debugging is enabled, but message debugging is disabled.static final intDeprecated.flags the state where warning debugging is enabled, but message debugging is disabled. -
Method Summary
Modifier and TypeMethodDescriptionvoidDeprecated.Prints error messages only when debug level is greater than DEBUG.OFF.voidDeprecated.A convenience method for error debug statements.voidDeprecated.Prints error messages only if debug state is greater than Debug.OFF.booleanDeprecated.Checks if error debugging is enabled.static DebuggetInstance(String debugName) Deprecated.Gets an existing instance of Debug for the specified debug name or a new one if no such instance already exists.static Collection<Debug>Deprecated.Returns a collection of all Debug instances that exist in the system at the current instance.getName()Deprecated.Convinience method to query the name being used for this Debug instance.intgetState()Deprecated.Returns one of the five possible values: Debug.OFF Debug.ERROR Debug.WARNING Debug.MESSAGE Debug.ONvoidDeprecated.Prints messages only when the debug state is either Debug.MESSAGE or Debug.ON.voidDeprecated.A convenience method for message debug statements.voidDeprecated.Prints debug and exception messages only when the debug state is either Debug.MESSAGE or Debug.ON.booleanDeprecated.Checks if message debugging is enabled.voidresetDebug(String mf) Deprecated.Allows runtime modification of the backend used by this instance.voidsetDebug(int debugType) Deprecated.Sets the debug capabilities based on the values of thedebugTypeargument.voidDeprecated.Sets the debug capabilities based on the values of thedebugTypeargument.voidDeprecated.Prints warning messages only when debug level is greater than Debug.ERROR.voidDeprecated.A convenience method for warning debug statements.voidDeprecated.Prints warning messages only when debug level is greater than Debug.ERROR.booleanDeprecated.Checks if warning debugging is enabled.
-
Field Details
-
OFF
public static final int OFFDeprecated.flags the disabled debug state.- See Also:
-
ERROR
public static final int ERRORDeprecated.flags the state where error debugging is enabled. When debugging is set to less thanERROR, error debugging is also disabled.- See Also:
-
WARNING
public static final int WARNINGDeprecated.flags the state where warning debugging is enabled, but message debugging is disabled. When debugging is set to less thanWARNING, warning debugging is also disabled.- See Also:
-
MESSAGE
public static final int MESSAGEDeprecated.This state enables debugging of messages, warnings and errors.- See Also:
-
ON
public static final int ONDeprecated.flags the enabled debug state for warnings, errors and messages. Printing to a file is disabled. All printing is done on System.out.- See Also:
-
STR_OFF
Deprecated.flags the disabled debug state.- See Also:
-
STR_ERROR
Deprecated.flags the state where error debugging is enabled. When debugging is set to less thanERROR, error debugging is also disabled.- See Also:
-
STR_WARNING
Deprecated.flags the state where warning debugging is enabled, but message debugging is disabled. When debugging is set to less thanWARNING, warning debugging is also disabled.- See Also:
-
STR_MESSAGE
Deprecated.This state enables debugging of messages, warnings and errors.- See Also:
-
STR_ON
Deprecated.flags the enables debug state for warnings, errors and messages. Printing to a file is disabled. All printing is done on System.out.- See Also:
-
-
Method Details
-
getInstance
Deprecated.Gets an existing instance of Debug for the specified debug name or a new one if no such instance already exists. If a Debug object has to be created, its level is set to the level defined in theAMConfig.propertiesfile. The level can be changed later by usingsetDebug(int)orsetDebug(String)methods.- Parameters:
debugName- name of the debug instances to be created- Returns:
- a Debug instance corresponding to the specified debug name.
-
getInstances
Deprecated.Returns a collection of all Debug instances that exist in the system at the current instance. This is a live collection that will be updated as and when new Debug instances are created. Note that if an iterator is used, it could potentially cause aConcurrentModificationExceptionif during the process of iteration, the collection is modified by the system.- Returns:
- a collection of all Debug instances in the system.
-
getName
Deprecated.Convinience method to query the name being used for this Debug instance. The return value of this method is a string exactly equal to the name that was used while creating this instance.- Returns:
- the name of this Debug instance
-
messageEnabled
public boolean messageEnabled()Deprecated.Checks if message debugging is enabled.
NOTE: Debugging is an IO intensive operation and may hurt application performance when abused. Particularly, note that Java evaluates arguments to
message()even when debugging is turned off. It is recommended thatmessageEnabled()be called to check the debug state before invoking anymessage()methods to avoid unnecessary argument evaluation and maximize application performance.- Returns:
trueif message debugging is enabledfalseif message debugging is disabled
-
warningEnabled
public boolean warningEnabled()Deprecated.Checks if warning debugging is enabled.
NOTE: Debugging is an IO intensive operation and may hurt application performance when abused. Particularly, note that Java evaluates arguments to
warning()even when warning debugging is turned off. It is recommended thatwarningEnabled()be called to check the debug state before invoking anywarning()methods to avoid unnecessary argument evaluation and maximize application performance.- Returns:
trueif warning debugging is enabledfalseif warning debugging is disabled
-
errorEnabled
public boolean errorEnabled()Deprecated.Checks if error debugging is enabled.
NOTE: Debugging is an IO intensive operation and may hurt application performance when abused. Particularly, note that Java evaluates arguments to
error()even when error debugging is turned off. It is recommended thaterrorEnabled()be called to check the debug state before invoking anyerror()methods to avoid unnecessary argument evaluation and maximize application performance.- Returns:
trueif error debugging is enabledfalseif error debugging is disabled
-
getState
public int getState()Deprecated.Returns one of the five possible values:- Debug.OFF
- Debug.ERROR
- Debug.WARNING
- Debug.MESSAGE
- Debug.ON
- Returns:
- the debug level
-
message
Deprecated.Prints messages only when the debug state is either Debug.MESSAGE or Debug.ON.
NOTE: Debugging is an IO intensive operation and may hurt application performance when abused. Particularly, note that Java evaluates arguments to
message()even when debugging is turned off. So when the argument to this method involves the String concatenation operator '+' or any other method invocation,messageEnabledMUST be used. It is recommended that the debug state be checked by invokingmessageEnabled()before invoking anymessage()methods to avoid unnecessary argument evaluation and maximize application performance.- Parameters:
msg- debug message.- See Also:
-
message
Deprecated.Prints debug and exception messages only when the debug state is either Debug.MESSAGE or Debug.ON. If the debug file is not accessible and debugging is enabled, the message along with a time stamp and thread info will be printed on
System.out.This method creates the debug file if does not exist; otherwise it starts appending to the existing debug file. When invoked for the first time on this object, the method writes a line delimiter of '*'s.
Note that the debug file will remain open until
destroy()is invoked. To conserve file resources, you should invokedestroy()explicitly rather than wait for the garbage collector to clean up.NOTE: Debugging is an IO intensive operation and may hurt application performance when abused. Particularly, note that Java evaluates arguments to
message()even when debugging is turned off. It is recommended that the debug state be checked by invokingmessageEnabled()before invoking anymessage()methods to avoid unnecessary argument evaluation and to maximize application performance.- Parameters:
msg- message to be printed. A newline will be appended to the message before printing either toSystem.outor to the debug file. Ifmsgis null, it is ignored.t-Throwable, on whichprintStackTracewill be invoked to print the stack trace. Iftis null, it is ignored.- See Also:
-
message
Deprecated.A convenience method for message debug statements. The message will only be formatted if the debug level is greater than
WARNING, and then it will be formatted using theMessageFormatterclass. The relevantmessagemethod is then called depending on whether the last parameter is an instance ofThrowable.This method is convenient way of issuing warning level debug statements without having to guard the call with a check to
messageEnabled(), as that check is done before evaluating the method parameters.For this optimisation to work properly, this method should not be called using string concatenation. If concatenation is required, it can be achieved using format patterns.
In this way, the only cost to execution is the assembly of the varargs parameter.
- Parameters:
msg- The debug message format, usingMessageFormatterstyle format patterns.params- The parameters to the message, optionally with aThrowableas the last parameter.
-
warning
Deprecated.Prints warning messages only when debug level is greater than Debug.ERROR.
NOTE: Debugging is an IO intensive operation and may hurt application performance when abused. Particularly, note that Java evaluates arguments to
warning()even when debugging is turned off. So when the argument to this method involves the String concatenation operator '+' or any other method invocation,warningEnabledMUST be used. It is recommended that the debug state be checked by invokingwarningEnabled()before invoking anywarning()methods to avoid unnecessary argument evaluation and to maximize application performance.- Parameters:
msg- message to be printed. A newline will be appended to the message before printing either toSystem.outor to the debug file. Ifmsgis null, it is ignored.- See Also:
-
warning
Deprecated.Prints warning messages only when debug level is greater than Debug.ERROR.
NOTE: Debugging is an IO intensive operation and may hurt application performance when abused. Particularly, note that Java evaluates arguments to
warning()even when debugging is turned off. It is recommended that the debug state be checked by invokingwarningEnabled()before invoking anywarning()methods to avoid unnecessary argument evaluation and to maximize application performance.If the debug file is not accessible and debugging is enabled, the message along with a time stamp and thread info will be printed on
System.out.This method creates the debug file if does not exist; otherwise it starts appending to the existing debug file. When invoked for the first time on this object, the method writes a line delimiter of '*'s.
Note that the debug file will remain open until
destroy()is invoked. To conserve file resources, you should invokedestroy()explicitly rather than wait for the garbage collector to clean up.- Parameters:
msg- message to be printed. A newline will be appended to the message before printing either toSystem.outor to the debug file. Ifmsgis null, it is ignored.t-Throwable, on whichprintStackTrace()will be invoked to print the stack trace. Iftis null, it is ignored.
-
warning
Deprecated.A convenience method for warning debug statements. The message will only be formatted if the debug level is greater than
ERROR, and then it will be formatted using theMessageFormatterclass. The relevantwarningmethod is then called depending on whether the last parameter is an instance ofThrowable.This method is convenient way of issuing warning level debug statements without having to guard the call with a check to
warningEnabled(), as that check is done before evaluating the method parameters.For this optimisation to work properly, this method should not be called using string concatenation. If concatenation is required, it can be achieved using format patterns.
In this way, the only cost to execution is the assembly of the varargs parameter.
- Parameters:
msg- The debug message format, usingMessageFormatterstyle format patterns.params- The parameters to the message, optionally with aThrowableas the last parameter.
-
error
Deprecated.Prints error messages only when debug level is greater than DEBUG.OFF.- Parameters:
msg- message to be printed. A newline will be appended to the message before printing either toSystem.outor to the debug file. Ifmsgis null, it is ignored.- See Also:
-
error
Deprecated.Prints error messages only if debug state is greater than Debug.OFF. If the debug file is not accessible and debugging is enabled, the message along with a time stamp and thread info will be printed on
System.out.This method creates the debug file if does not exist; otherwise it starts appending to the existing debug file. When invoked for the first time on this object, the method writes a line delimiter of '*'s.
Note that the debug file will remain open until
destroy()is invoked. To conserve file resources, you should invokedestroy()explicitly rather than wait for the garbage collector to clean up.- Parameters:
msg- message to be printed. A newline will be appended to the message before printing either toSystem.outor to the debug file. Ifmsgis null, it is ignored.t-Throwable, on whichprintStackTrace()will be invoked to print the stack trace. Iftis null, it is ignored.
-
error
Deprecated.A convenience method for error debug statements. The message will only be formatted if the debug level is greater than
OFF, and then it will be formatted using theMessageFormatterclass. The relevanterrormethod is then called depending on whether the last parameter is an instance ofThrowable.This method is convenient way of issuing warning level debug statements without having to guard the call with a check to
errorEnabled(), as that check is done before evaluating the method parameters.For this optimisation to work properly, this method should not be called using string concatenation. If concatenation is required, it can be achieved using format patterns.
In this way, the only cost to execution is the assembly of the varargs parameter.
- Parameters:
msg- The debug message format, usingMessageFormatterstyle format patterns.params- The parameters to the message, optionally with aThrowableas the last parameter.
-
setDebug
public void setDebug(int debugType) Deprecated.Sets the debug capabilities based on the values of thedebugTypeargument.- Parameters:
debugType- is any one of five possible values:Debug.OFFDebug.ERRORDebug.WARNINGDebug.MESSAGEDebug.ON
-
resetDebug
Deprecated.Allows runtime modification of the backend used by this instance. by resetting the debug instance to reinitialize itself.- Parameters:
mf- merge flag - on for creating a single debug file.
-
setDebug
Deprecated.Sets the debug capabilities based on the values of thedebugTypeargument.- Parameters:
debugType- is any one of the following possible values:Debug.STR_OFFDebug.STR_ERRORDebug.STR_WARNINGDebug.STR_MESSAGEDebug.STR_ON
-
Loggerinstead.