16
parser_logger = logging.getLogger("CSHEL_parserlogger"); #logging.basicConfig() parser_logger.addHandler(RotatingFileHandler( "logfile", mode='a', maxBytes=7340032, backupCount=4, encoding=None, delay=False)) #d = { 'clientip' : '192.168.0.1', 'user' : 'fbloggs' } parser_logger.info('Protocol problem: %s', 'connection reset') 

This would create a file named logfile, but won't write anything into it. If I change the last line to

parser_logger.warning('Protocol problem: %s', 'connection reset') 

it would log the message into the "logfile" properly.

I am sure it's a petty thing that I am missing, but I am not able to figure out what it is.

1 Answer 1

24

You need to set the threshold level of the logger:

parser_logger.setLevel(logging.INFO) 

When a logger is created, the level is set to NOTSET, and the root logger is created with level WARNING. See the documentation.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.