logging.basic config code example
Example 1: logging.logger
import logging
logging.basicConfig(level=logging.WARNING)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.debug("some debugging...")
logger.error("some error...")
Example 2: what do you use for logging
I use Log4J for logging.
I always log important steps in the test
execution. That helps me to debug
when there is a failure.
Log4J is not a replacement for HTML reports.
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j- core</artifactId>
<version>2.11.0</version>
</dependency>
Example 3: logging.debug vs logger
Logger logger = Logger.getLogger("com.foo");
logger.setLevel(Level.INFO);
Logger barlogger = Logger.getLogger("com.foo.Bar");
logger.warn("Low fuel level.");
logger.debug("Starting search for nearest gas station.");
barlogger.info("Located nearest gas station.");
barlogger.debug("Exiting gas station search");