Package oracle.jdbc.diagnostics
Class Diagnostic
- java.lang.Object
-
- oracle.jdbc.diagnostics.Diagnostic
-
public class Diagnostic extends java.lang.Object
This class implements Oracle JDBC Diagnostic methods for diagnose first failure recording and diagnostic logging. Use of this class ensures that all LogRecords include TraceAttributes.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Diagnostic(java.lang.String loggerName, int recordsCount)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConfig(java.util.Properties properties)
protected static void
addErrorCodeToWatchList(java.lang.String errorCode)
protected static void
clearExceptionKeywords()
<T extends java.lang.Throwable>
Tdebug(java.util.logging.Level level, SecurityLabel label, java.lang.String sourceClass, java.lang.String sourceMethod, TraceAttributes attributes, T thrown, java.lang.String publicMessage, java.lang.String sensitiveMessage, java.lang.Object... params)
Creates a Diagnose First Failure entry.void
dumpDiagnoseFirstFailure(boolean isDumpSystemConfig)
Push the Diagnose First Failure records to the target Handler.protected static void
dumpDiagnoseFirstFailureWhenNextExceptionContains(java.lang.String commaSeparatedKeywords)
void
enableDiagnoseFirstFailureDump(boolean enableDump)
Enables or disables the automatic dump of Diagnose First Failure data on error.void
enableSensitive(boolean enabled)
static Diagnostic
get(java.lang.String loggerName, int size)
Factory method for creating Diagnostics.protected static java.lang.String
getErrorCodesWatchList()
protected static java.lang.String
getExceptionKeywords()
boolean
isSensitiveEnabled()
protected static void
removeErrorCodeFromWatchList(java.lang.String errorCode)
protected static void
resetErrorCodeWatchList()
void
setDiagnoseFirstFailureBufferSize(int bufferSize)
void
setLoggingLevel(java.lang.String newLevel)
<T extends java.lang.Throwable>
Ttrace(java.util.logging.Level level, SecurityLabel label, java.lang.String sourceClass, java.lang.String sourceMethod, TraceAttributes attributes, T thrown, java.lang.String publicMessage, java.lang.String sensitiveMessage, java.lang.Object... params)
Creates a diagnostic Diagnose First Failure entry.
-
-
-
Method Detail
-
get
public static Diagnostic get(java.lang.String loggerName, int size)
Factory method for creating Diagnostics. At least for now it should create a new Diagnostic each time it is called even if the Logger name is the same as an existing Diagnostic. This is to prevent concurrent access.- Parameters:
loggerName
- the name of theLogger
used to write log recordssize
- the size of the ring buffer used to store Diagnose First Failure records
-
addConfig
public void addConfig(java.util.Properties properties)
-
enableSensitive
public final void enableSensitive(boolean enabled)
-
isSensitiveEnabled
public boolean isSensitiveEnabled()
-
enableDiagnoseFirstFailureDump
public void enableDiagnoseFirstFailureDump(boolean enableDump)
Enables or disables the automatic dump of Diagnose First Failure data on error.- Parameters:
enableDump
- enable or disable automatic dump of Diagnose First Failure data
-
trace
public <T extends java.lang.Throwable> T trace(java.util.logging.Level level, SecurityLabel label, java.lang.String sourceClass, java.lang.String sourceMethod, TraceAttributes attributes, T thrown, java.lang.String publicMessage, java.lang.String sensitiveMessage, java.lang.Object... params)
Creates a diagnostic Diagnose First Failure entry. If only Diagnose First Failure is enabled the data is saved in the connection ring buffer. If Diagnose First Failure is enabled the record is written to a Logger. The messages should be String literals or concatenations of String literals, nothing more. See java.text.MessageFormat for details on the format of the messages. The parameters must be public values first followed by the SENSITIVE marker followed by any sensitive values. If there are no sensitive values the marker may be omitted. The publicMessage may only refer to public parameter values.- Parameters:
level
- the Level of the log entry. May not be nullsourceClass
- the fully qualified name of the class containing the call to this method. May not be nullsourceMethod
- the name of the method containing the call to this method. May not be nullattributes
- the current attributes of the environment containing this call. May be nullthrown
- the Throwable for the logRecord if any. May be nullpublicMessage
- the message for the LogRecord if sensitive mode is not enabled. May not be nullsensitiveMessage
- the message for the LogRecord if sensitive mode is enabled. May be nullparams
- the parameters for the message, public parameters first, then the SENSITIVE marker, then sensitive parameters. If no sensitive parameters the marker may be omitted. May be null- Returns:
thrown
-
debug
public <T extends java.lang.Throwable> T debug(java.util.logging.Level level, SecurityLabel label, java.lang.String sourceClass, java.lang.String sourceMethod, TraceAttributes attributes, T thrown, java.lang.String publicMessage, java.lang.String sensitiveMessage, java.lang.Object... params)
Creates a Diagnose First Failure entry. If Diagnose First Failure is enabled the record is written to a Logger. The messages should be String literals or concatenations of String literals, nothing more. See java.text.MessageFormat for details on the format of the messages. The parameters must be public values first followed by the SENSITIVE marker followed by any sensitive values. If there are no sensitive values the marker may be omitted. The publicMessage may only refer to public parameter values.- Parameters:
level
- the Level of the log entry. May not be nulllabel
- security labelsourceClass
- the fully qualified name of the class containing the call to this method. May not be nullsourceMethod
- the name of the method containing the call to this method. May not be nullattributes
- the current attributes of the environment containing this call. May be nullthrown
- the Throwable for the logRecord if any. May be nullpublicMessage
- the message for the LogRecord if sensitive mode is not enabled. May not be nullsensitiveMessage
- the message for the LogRecord if sensitive mode is enabled. May be nullparams
- the parameters for the message, public parameters first, then the SENSITIVE marker, then sensitive parameters. If no sensitive parameters the marker may be omitted. May be null- Returns:
thrown
-
setLoggingLevel
public void setLoggingLevel(java.lang.String newLevel)
-
addErrorCodeToWatchList
protected static void addErrorCodeToWatchList(java.lang.String errorCode)
-
removeErrorCodeFromWatchList
protected static void removeErrorCodeFromWatchList(java.lang.String errorCode)
-
getErrorCodesWatchList
protected static java.lang.String getErrorCodesWatchList()
-
resetErrorCodeWatchList
protected static void resetErrorCodeWatchList()
-
setDiagnoseFirstFailureBufferSize
public void setDiagnoseFirstFailureBufferSize(int bufferSize)
-
dumpDiagnoseFirstFailureWhenNextExceptionContains
protected static void dumpDiagnoseFirstFailureWhenNextExceptionContains(java.lang.String commaSeparatedKeywords)
-
getExceptionKeywords
protected static java.lang.String getExceptionKeywords()
-
clearExceptionKeywords
protected static void clearExceptionKeywords()
-
dumpDiagnoseFirstFailure
public void dumpDiagnoseFirstFailure(boolean isDumpSystemConfig)
Push the Diagnose First Failure records to the target Handler.- Parameters:
isDumpSystemConfig
- Whether add config parameters to the Diagnose First Failure before pushing to the target handler.
-
-