logging format 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: from logging import logger

#!/usr/bin/env python3
# -*- coding: UTF-8 -*-

import logging

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG)

logger.debug('Loging %s lewel', 'DEBUG')
logger.info('Loging %s lewel', 'INFO')
logger.warning('Loging %s lewel', 'WARN')
logger.error('Loging %s lewel', 'ERROR')
logger.critical('Loging %s lewel', 'CRITICAL')

Example 3: 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>

Tags:

Misc Example