i want to create separate logging file in python like info.log, debug.log, error.log i have a setting file(logging.conf) for logging as given below
[loggers]
keys=root,simpleExample
[handlers]
keys=consoleHandler
[formatters]
keys=simpleFormatter
[logger_root]
level=DEBUG
handlers=consoleHandler
[logger_simpleExample]
level=DEBUG
handlers=consoleHandler
qualname=simpleExample
propagate=0
[handler_consoleHandler]
class=StreamHandler
level=DEBUG
formatter=simpleFormatter
args=(sys.stdout,)
[formatter_simpleFormatter]
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
datefmt=
and i have created logging.py file as given below
import logging
import logging.config
logging.config.fileConfig('logging.conf')
# create logger
logger = logging.getLogger('simpleExample')
# 'application' code
logger.debug('debug message')
logger.info('info message')
logger.warn('warn message')
logger.error('error message')
logger.critical('critical message')
but when execute logging.py file i am getting following result in consol
2012-12-10 13:30:20,030 - simpleExample - DEBUG - debug message
2012-12-10 13:30:20,031 - simpleExample - INFO - info message
2012-12-10 13:30:20,032 - simpleExample - WARNING - warn message
2012-12-10 13:30:20,032 - simpleExample - ERROR - error message
2012-12-10 13:30:20,033 - simpleExample - CRITICAL - critical message
as i have told i want to create separate file in log.info, debug.info, error.info. thanks in advance
loggingmodule documentation really. I'd rethink why you'd want to have separate files in the first place.