The Logger object is used to log messages.
The message will be displayed:
When running a test:
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.
NeoLoad provides a predefined Logger named logger
Example
logger.error("Unexpected value:"+var1);
public class Logger {
// Public Methodspublic 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);
}
public void debug(String message);
Parameters
message
Log a message at DEBUG level, will be logged if runtime level is DEBUG.
public void error(String message);
Parameters
message
Log a message at ERROR level, will be logged if runtime level is lower or equal to ERROR.
method, described in fail(String).public void fatal(String message);
Parameters
message
Log a message at FATAL level, will always be logged.
public void info(String message);
Parameters
message
Log a message at INFO level, will be logged if runtime level is lower or equal to INFO.
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.
public boolean isErrorEnabled();
Parameters
return
true
if this logger is error enabled, false
otherwise.Check whether this logger is enabled for the ERROR
Level.
For more information, see isDebugEnabled().
public boolean isFatalEnabled();
Parameters
return
true
if this logger is fatal enabled, false
otherwise.Check whether this logger is enabled for the FATAL
Level.
For more information, see isDebugEnabled().
public boolean isInfoEnabled();
Parameters
return
true
if this logger is info enabled, false
otherwise.Check whether this logger is enabled for the INFO
Level.
For more information, see isDebugEnabled().
public boolean isWarnEnabled();
Parameters
return
true
if this logger is warn enabled, false
otherwise.
Check whether this logger is enabled for the WARN
Level.
For more information, see isDebugEnabled().
public void warn(String message);
Parameters
message
Log a message at WARN level, will be logged if runtime level is lower or equal to WARN.