public interface LogService extends Service
Viewing these logs must be enabled per user with the Logs: Vault Java SDK permission.
Vault Java SDK log messages can be static Strings or constructed with a template. It is best practice to use
message templates over String concatenation because templates are more efficient and produce neater, easier to read
code. Strings for message templates are only constructed if logging is enabled, whereas String concatenation must be
wrapped in an if
statement to check enablement.
For example:
logService.info("Exceeded the {} limit of {}.", limitType, count);
Is equivalent to:
if (log.isInfoEnabled()){
logService.info("Exceeded the " + limitType + " limit of " + count + ".");
}
There are two configurable log types available for the Vault Java SDK Logs:
isDebugEnabled()
, isInfoEnabled()
, isWarnEnabled()
and
isErrorEnabled()
returns true if logging will occur in either the Debug Log or the Runtime Log. It
returns false if logging will not occur in any of the Vault Java SDK Logs.
You can choose between the DEBUG, INFO, ERROR, and WARN types to categorize your debug log messages.
You can choose between the DISABLED, EXCEPTIONS, ERROR, WARN, and INFO types to customize the granularity of these log entries, available in Admin > Settings > General Settings. The ability to update the granularity of log levels must be enabled per user with the Settings: General Configuration permission. Changing the log level only impacts new entries added to the log.
Modifier and Type | Method and Description |
---|---|
void |
debug(String message)
Outputs a DEBUG type message to the Debug Log.
|
void |
debug(String messageTemplate,
Object... args)
Outputs the templated DEBUG type message to the Debug Log.
|
void |
debug(Supplier<String> messageSupplier)
Output the String returned from a single call to messageSupplier.get() to the Debug Log.
|
void |
error(String message)
Outputs an ERROR type message to the Debug Log and Runtime Log.
|
void |
error(String messageTemplate,
Object... args)
Outputs the templated ERROR type message to the Debug Log and Runtime Log.
|
void |
error(Supplier<String> messageSupplier)
Output the String returned from a single call to messageSupplier.get() to the Debug Log and Runtime Log.
|
void |
info(String message)
Outputs an INFO type message to the Debug Log and Runtime Log.
|
void |
info(String messageTemplate,
Object... args)
Outputs the templated INFO type message to the Debug Log and Runtime Log.
|
void |
info(Supplier<String> messageSupplier)
Output the String returned from a single call to messageSupplier.get() to the Debug Log and Runtime Log.
|
boolean |
isDebugEnabled()
Checks if the Debug Log is enabled.
|
boolean |
isErrorEnabled()
Checks if the Debug Log or Runtime Log is enabled.
|
boolean |
isInfoEnabled()
Checks if the Debug Log or Runtime Log is enabled.
|
boolean |
isWarnEnabled()
Checks if the Debug Log or Runtime Log is enabled.
|
void |
logResourceUsage(String message)
Outputs current resource usage for elapsed time (milliseconds), memory (bytes), and CPU time (nanoseconds)
to the Debug Log.
|
void |
warn(String message)
Outputs an WARN type message to the Debug Log and Runtime Log.
|
void |
warn(String messageTemplate,
Object... args)
Outputs the templated WARN type message to the Debug Log and Runtime Log.
|
void |
warn(Supplier<String> messageSupplier)
Output the String returned from a single call to messageSupplier.get() to the Debug Log and Runtime Log.
|
boolean isDebugEnabled()
boolean isInfoEnabled()
boolean isWarnEnabled()
boolean isErrorEnabled()
void debug(String message)
message
- message to outputvoid info(String message)
message
- message to outputvoid warn(String message)
message
- message to outputvoid error(String message)
message
- message to outputvoid logResourceUsage(String message)
Outputs current resource usage for elapsed time (milliseconds), memory (bytes), and CPU time (nanoseconds) to the Debug Log.
For example:
"message": elapsed(ms)=35 memory(b)=25744 CPU(ns)=28831998
message
- message to output in addition to resource usagevoid debug(String messageTemplate, Object... args)
Outputs the templated DEBUG type message to the Debug Log.
The messageTemplate
may contain the template variable {}
. The number of template
variables must match the number of arguments passed to the method. Arguments are converted to Strings
with toString()
for Object arguments and String.valueOf(_)
for primitive arguments.
Instances of {}
in the message template are replaced, in order, with the converted String values of
the arguments.
For example:
logService.debug("The {} limit of {} has been reached.", limitType, count);
messageTemplate
- message templateargs
- arguments to replace the {} variables in the templatevoid info(String messageTemplate, Object... args)
Outputs the templated INFO type message to the Debug Log and Runtime Log.
The messageTemplate
may contain the template variable {}
. The number of template
variables must match the number of arguments passed to the method. Arguments are converted to Strings
with toString()
for Object arguments and String.valueOf(_)
for primitive arguments.
Instances of {}
in the message template are replaced, in order, with the converted String value
of the arguments.
For example:
logService.debug("The {} limit of {} has been reached.", limitType, count);
messageTemplate
- message templateargs
- arguments to replace the {} variables in the templatevoid warn(String messageTemplate, Object... args)
Outputs the templated WARN type message to the Debug Log and Runtime Log.
The messageTemplate
may contain the template variable {}
. The number of template
variables must match the number of arguments passed to the method. Arguments are converted to Strings
with toString()
for Object arguments and String.valueOf(_)
for primitive arguments.
Instances of {}
in the message template are replaced, in order, with the converted String values of
the arguments.
For example:
logService.debug("The {} limit of {} has been reached.", limitType, count);
messageTemplate
- message templateargs
- arguments to replace the {} variables in the templatevoid error(String messageTemplate, Object... args)
Outputs the templated ERROR type message to the Debug Log and Runtime Log.
The messageTemplate
may contain the template variable {}
. The number of template
variables must match the number of arguments passed to the method. Arguments are converted to Strings
with toString()
for Object arguments and String.valueOf(_)
for primitive arguments.
Instances of {}
in the message template are replaced, in order, with the converted String values of
the arguments.
For example:
logService.debug("The {} limit of {} has been reached.", limitType, count);
messageTemplate
- message templateargs
- arguments to replace the {} variables in the templatevoid debug(Supplier<String> messageSupplier)
messageSupplier
- supplier providing a message to outputvoid info(Supplier<String> messageSupplier)
messageSupplier
- supplier providing a message to outputvoid warn(Supplier<String> messageSupplier)
messageSupplier
- supplier providing a message to outputCopyright © Veeva Systems 2017–2022. All rights reserved.