Logger Class

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);

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

Log a message at DEBUG level, will be logged if runtime level is DEBUG.

error(String)

public void error(String message);

Parameters

Log a message at ERROR level, will be logged if runtime level is lower or equal to ERROR.

fatal(String)

public void fatal(String message);

Parameters

Log a message at FATAL level, will always be logged.

info(String)

public void info(String message);

Parameters

Log a message at INFO level, will be logged if runtime level is lower or equal to INFO.

isDebugEnabled()

public boolean isDebugEnabled();

Parameters

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

Check whether this logger is enabled for the ERROR Level.

For more information, see isDebugEnabled().

isFatalEnabled()

public boolean isFatalEnabled();

Parameters

Check whether this logger is enabled for the FATAL Level.

For more information, see isDebugEnabled().

isInfoEnabled()

public boolean isInfoEnabled();

Parameters

Check whether this logger is enabled for the INFO Level.

For more information, 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.

For more information, see isDebugEnabled().

warn(String)

public void warn(String message);

Parameters

Log a message at WARN level, will be logged if runtime level is lower or equal to WARN.