user3593486
user3593486

Reputation: 57

Python 3.2 Logging handlers 'nonetype object has no attribute setLevel()'

I followed the documentation as carefully, but somehow creating the handler doesnt seem to be working.

import logging
import logging.handlers

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

# create handlers and set levels
qaHandler = logger.addHandler(logging.handlers.TimedRotatingFileHandler('%sQA.log'%__name__,when='midnight', backupCount=3))
qaHandler.setLevel(logging.INFO)

Thats the code, what have I missed?

Upvotes: 2

Views: 4385

Answers (1)

Klaus D.
Klaus D.

Reputation: 14404

addHandler() does not return the handler but None. Put the handler into a variable, then use the variable to add it.

Upvotes: 4

Related Questions