Class Logger
The Logger object is used to log messages.
The message will be displayed:
When running a test:
- in NeoLoad GUI when the Javascript failed for any reason,
- in the Load Generator log file in any case ("loadGenerator.log.00x" of the logs folder. Open the logs folder with the menu "Help / open logs folder").
When checking a User Path: in NeoLoad GUI only.
The different methods of this class log the message with different log levels: FATAL, ERROR, WARN, INFO, DEBUG. If the level used to log the message is lower than the log level defined in the runtime policy, then the message will be ignored.
The runtime log level can be set in NeoLoad GUI, in the project preferences: menu "Edit / Preferences". The default is ERROR, it will ignore any message at WARN, INFO and DEBUG level. Warning, as it can be very verbose, the runtime log level should be decreased to debug small tests only (few users for a few time). Do not forget to switch back to ERROR level for normal tests.
The log level is forced to DEBUG when validating your User Paths using the Check User Path dialog.
- Warning: Logging at ERROR level will not flag the JSAction as failed. If you want to flag the JSAction as failed, use the fail(String) method, described in fail(String).
NeoLoad provides a predefined Logger named logger
Example
logger.error("Unexpected value:"+var1);Synopsis
public class Logger {
// Public Methods
public void debug(String message);
public void error(String message);
public void fatal(String message);
public void info(String message);
public boolean isDebugEnabled();
public boolean isErrorEnabled();
public boolean isFatalEnabled();
public boolean isInfoEnabled();
public boolean isWarnEnabled();
public void warn(String message);
}debug(String)
public void debug(String message);Parameters
- message
the message.Log a message at DEBUG level, will be logged if runtime level is DEBUG.
error(String)
public void error(String message);Parameters
- message
the message.Log a message at ERROR level, will be logged if runtime level is lower or equal to ERROR.
- Warning: Logging at ERROR level will not flag the JSAction as failed. If you want to flag the JSAction as failed, use the fail(String) method, described in fail(String).
fatal(String)
public void fatal(String message);Parameters
- message
the message.Log a message at FATAL level, will always be logged.
info(String)
public void info(String message);Parameters
- message
the message.Log a message at INFO level, will be logged if runtime level is lower or equal to INFO.
isDebugEnabled()
public boolean isDebugEnabled();Parameters
- return
true if this logger is debug enabled, false otherwise.Check whether this logger is enabled for the DEBUG Level.
This function is intended to lessen the computational cost of disabled log debug statements.
For some JavaScript action, when you write,
logger.debug("This is entry number: " + i );You incur the cost constructing the message, concatenation in this case, regardless of whether the message is logged or not. You should write
if(logger.isDebugEnabled()) { logger.debug("This is entry number: " + i ); }This way you will not incur the cost of parameter construction if debugging is disabled for the session.
isErrorEnabled()
public boolean isErrorEnabled();Parameters
- return
true if this logger is error enabled, false otherwise.Check whether this logger is enabled for the ERROR Level.
See isDebugEnabled().
isFatalEnabled()
public boolean isFatalEnabled();Parameters
- return
true if this logger is fatal enabled, false otherwise.Check whether this logger is enabled for the FATAL Level.
See isDebugEnabled().
isInfoEnabled()
public boolean isInfoEnabled();Parameters
- return
true if this logger is info enabled, false otherwise.Check whether this logger is enabled for the INFO Level.
See isDebugEnabled().
isWarnEnabled()
public boolean isWarnEnabled();Parameters
return
true if this logger is warn enabled, false otherwise.Check whether this logger is enabled for the WARN Level.
See isDebugEnabled().
warn(String)
public void warn(String message);Parameters
- message
the message.Log a message at WARN level, will be logged if runtime level is lower or equal to WARN.
Home