The log Object

You can keep track of what happened while  executed your code by adding the log object to your code.  sends logs to the log object, which has a logging level. This logging level determines whether logging calls results in logging. If the logging level for the log object is higher than the logging call's logging level, then the logging call does not result in logging.
lac52
You can keep track of what happened while 
Layer7 Live API Creator
 executed your code by adding the 
log
 object to your code. 
Layer7 Live API Creator
 sends logs to the 
log
 object, which has a logging level. This logging level determines whether logging calls results in logging. If the logging level for the 
log
 object is higher than the logging call's logging level, then the logging call does not result in logging.
In the following example, the call does not result in logging because the logging level for the 
log
 object is 
info
, which is lower than the logging level for the logging calls, which is 
warn
:
log.info("My informational message");
In this article:
 
 
error() Method
Use the 
error()
 method to log messages at the error level. If the logging level is at or below the error level, then 
Layer7 Live API Creator
 outputs the following message:
log.error("This is a log error message");
warning() Method
Use the 
warning()
 method to log messages at the warning level. If the logging level is at or below the warning level, then 
Layer7 Live API Creator
 outputs the following message:
log.warning("This is a log warning message");
info() Method
Use the 
info()
 method to log messages at the info level. If the logging level is at or below the info level, then 
Layer7 Live API Creator
 outputs the following message:
log.info("This is a log info message");
debug() Method
Use the 
debug()
 method to log messages at the debug level. If the logging level is at or below the debug level, then 
Layer7 Live API Creator
 outputs the following message:
log.debug("This is a log debug message");
Logging can affect  
Layer7 Live API Creator
 performance, particularly if logging requires executing code that takes up a lot of resources. It is generally a good idea to log no more than required. Logging a fixed message using the 
log.debug()
 method is a low-resource option.
finer() Method
Use the 
finer()
 method to log messages at the finer level. If the logging level is at or below the finer level, then 
Layer7 Live API Creator
 outputs the following message:
log.finer("This is a log finer message");
finest() Method
Use the 
finest()
 method to log messages at the finest level. If the logging level is at or below the finest level, then 
Layer7 Live API Creator
 outputs the following message:
log.finest("This is a log finest message");
isErrorEnabled() Method
Use the 
isErrorEnabled()
 method to return 
true
 if the logging level is set to error.
isWarnEnabled() Method
Use the 
isWarnEnabled()
 method to return true if the logging level is set to the warning level or higher.
isInfoEnabled() Method
Use the 
isWarnEnabled()
 method to return true if the logging level is set to the info level or higher.
isDebugEnabled() Method
Use the 
isDebugEnabled()
 method to return true if the logging level is set to the debug level or higher.
If your logging message invokes other functions, or builds up a string from other objects, conditionalalize the logging message on the logging level, for example, using the 
log.isDebugEnabled()
 method:
if (log.isDebugEnabled()) {
log.debug("The value of foo is:" + foo.getValue() + " and the value of bar is:" + bar);
}
If you do not make the logging conditional on the logging level and you turn down the logging level, you still incur the cost of building this string, even though it is never actually logged.
isFinerEnabled() Method
Use the 
isFinerEnabled()
 method to return true if the logging level is set to the finer level or higher.
isFinestEnabled() Method
Use the 
isFinestEnabled()
 method to return true if the logging level is set to the finest level or higher.