Top Description Fields Constructors Methods
org.testng.log4testng

public Class Logger

extends Object
Class Inheritance
Imports
java.util.Map, org.slf4j.LoggerFactory, org.testng.collections.Maps

TestNG logging now uses slf4j logging facade to satisfy the logging needs. To control TestNG logging, please refer to the SLF4J logging facade documentation. TestNG internally uses SimpleLogger for logging purposes.

Field Summary

Modifier and TypeField and Description
private final Logger
private static final Map<Class<?>, Logger>
loggers

Map of all known loggers.

Constructor Summary

AccessConstructor and Description
private
Logger(Logger logger)

Method Summary

Modifier and TypeMethod and Description
public void
debug(Object
the message object to log.
message
)

Log a message object with the DEBUG level.

public void
debug(Object
the message object to log.
message
,
Throwable
the exception to log, including its stack trace.
t
)

Log a message object with the DEBUG level including the stack trace of the Throwable t passed as parameter.

public void
error(Object
the message object to log.
message
)

Log a message object with the ERROR level.

public void
error(Object
the message object to log.
message
,
Throwable
the exception to log, including its stack trace.
t
)

Log a message object with the DEBUG level including the stack trace of the Throwable t passed as parameter.

public void
fatal(Object
the message object to log.
message
)

Log a message object with the FATAL level.

public void
fatal(Object
the message object to log.
message
,
Throwable
the exception to log, including its stack trace.
t
)

Log a message object with the FATAL level including the stack trace of the Throwable t passed as parameter.

public static Logger

Returns:

a logger named according to the value of the pClass.getName().
getLogger
(Class<?>
The class' logger to retrieve.
pClass
)

Retrieve a logger named according to the value of the pClass.getName() parameter.

public void
info(Object
the message object to log.
message
)

Log a message object with the INFO level.

public void
info(Object
the message object to log.
message
,
Throwable
the exception to log, including its stack trace.
t
)

Log a message object with the WARN level including the stack trace of the Throwable t passed as parameter.

public boolean

Returns:

true if this logger is enabled for level DEBUG, false otherwise.
isDebugEnabled
()

Check whether this logger is enabled for the DEBUG Level.

public boolean

Returns:

true if this logger is enabled for level INFO, false otherwise.
isInfoEnabled
()

Check whether this logger is enabled for the INFO Level.

public boolean

Returns:

true if this logger is enabled for level TRACE, false otherwise.
isTraceEnabled
()

Check whether this logger is enabled for the TRACE Level.

public void
trace(Object
the message object to log.
message
)

Log a message object with the TRACE level.

public void
trace(Object
the message object to log.
message
,
Throwable
the exception to log, including its stack trace.
t
)

Log a message object with the TRACE level including the stack trace of the Throwable t passed as parameter.

public void
warn(Object
the message object to log.
message
)

Log a message object with the WARN level.

public void
warn(Object
the message object to log.
message
,
Throwable
the exception to log, including its stack trace.
t
)

Log a message object with the ERROR level including the stack trace of the Throwable t passed as parameter.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

loggerback to summary
private final Logger logger
loggersback to summary
private static final Map<Class<?>, Logger> loggers

Map of all known loggers.

Constructor Detail

Loggerback to summary
private Logger(Logger logger)

Method Detail

debugback to summary
public void debug(Object message)

Log a message object with the DEBUG level. See Logger.trace(Object) form for more detailed information.

Parameters
message:Object

the message object to log.

debugback to summary
public void debug(Object message, Throwable t)

Log a message object with the DEBUG level including the stack trace of the Throwable t passed as parameter. See Logger.trace(Object, Throwable) form for more detailed information.

Parameters
message:Object

the message object to log.

t:Throwable

the exception to log, including its stack trace.

errorback to summary
public void error(Object message)

Log a message object with the ERROR level. See Logger.trace(Object) form for more detailed information.

Parameters
message:Object

the message object to log.

errorback to summary
public void error(Object message, Throwable t)

Log a message object with the DEBUG level including the stack trace of the Throwable t passed as parameter. See Logger.trace(Object, Throwable) form for more detailed information.

Parameters
message:Object

the message object to log.

t:Throwable

the exception to log, including its stack trace.

fatalback to summary
public void fatal(Object message)

Log a message object with the FATAL level. See Logger.trace(Object) form for more detailed information.

Parameters
message:Object

the message object to log.

fatalback to summary
public void fatal(Object message, Throwable t)

Log a message object with the FATAL level including the stack trace of the Throwable t passed as parameter. See Logger.trace(Object, Throwable) form for more detailed information.

Parameters
message:Object

the message object to log.

t:Throwable

the exception to log, including its stack trace.

getLoggerback to summary
public static Logger getLogger(Class<?> pClass)

Retrieve a logger named according to the value of the pClass.getName() parameter. If the named logger already exists, then the existing instance will be returned. Otherwise, a new instance is created. By default, loggers do not have a set level but inherit it from their nearest ancestor with a set level.

Parameters
pClass:Class<?>

The class' logger to retrieve.

Returns:Logger

a logger named according to the value of the pClass.getName().

infoback to summary
public void info(Object message)

Log a message object with the INFO level. See Logger.trace(Object) form for more detailed information.

Parameters
message:Object

the message object to log.

infoback to summary
public void info(Object message, Throwable t)

Log a message object with the WARN level including the stack trace of the Throwable t passed as parameter. See Logger.trace(Object, Throwable) form for more detailed information.

Parameters
message:Object

the message object to log.

t:Throwable

the exception to log, including its stack trace.

isDebugEnabledback to summary
public boolean isDebugEnabled()

Check whether this logger is enabled for the DEBUG Level.

Returns:boolean

true if this logger is enabled for level DEBUG, false otherwise.

isInfoEnabledback to summary
public boolean isInfoEnabled()

Check whether this logger is enabled for the INFO Level.

Returns:boolean

true if this logger is enabled for level INFO, false otherwise.

isTraceEnabledback to summary
public boolean isTraceEnabled()

Check whether this logger is enabled for the TRACE Level.

Returns:boolean

true if this logger is enabled for level TRACE, false otherwise.

traceback to summary
public void trace(Object message)

Log a message object with the TRACE level. This method first checks if this logger is TRACE enabled. If this logger is TRACE enabled, then it converts the message object (passed as parameter) to a string by invoking toString(). WARNING Note that passing a Throwable to this method will print the name of the Throwable but no stack trace. To print a stack trace use the trace(Object, Throwable) form instead.

Parameters
message:Object

the message object to log.

traceback to summary
public void trace(Object message, Throwable t)

Log a message object with the TRACE level including the stack trace of the Throwable t passed as parameter. See Logger.trace(Object) form for more detailed information.

Parameters
message:Object

the message object to log.

t:Throwable

the exception to log, including its stack trace.

warnback to summary
public void warn(Object message)

Log a message object with the WARN level. See Logger.trace(Object) form for more detailed information.

Parameters
message:Object

the message object to log.

warnback to summary
public void warn(Object message, Throwable t)

Log a message object with the ERROR level including the stack trace of the Throwable t passed as parameter. See Logger.trace(Object, Throwable) form for more detailed information.

Parameters
message:Object

the message object to log.

t:Throwable

the exception to log, including its stack trace.