Configuration file for logging

This is the place for queries that don't fit in any of the other categories.

Configuration file for logging

Postby askance » Tue Oct 22, 2013 8:02 pm

I think I'm missing something big and for the life of me, I can't figure it out. I have a logging.conf file that I am trying my main (say, xyz.py) file to read. But I am getting this weird error. I have the traceback below followed by the configuration file - logging.conf and then the relevant part in xyz.py.

Code: Select all
File "xyz.py", line 28, in <module>
log = logging.config.fileConfig('/Users/Username/Desktop/logging.conf')
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py", line 78, in fileConfig
handlers = _install_handlers(cp, formatters)
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py", line 156, in _install_handlers
h = klass(*args)
TypeError: __init__() takes at most 7 arguments (23 given)



The configuration file - full path = /Users/Username/Desktop/logging.config (I followed the instruction from http://docs.python.org/release/2.5.2/li ... ormat.html)

Code: Select all
[loggers]
keys=root

[handlers]
keys=handlersmtp, handlerfile

[formatters]
keys=formatter

[formatter_formatter]
format=%(asctime)s %(name)s %(levelname)s %(message)s
datefmt=
class=logging.Formatter

[logger_root]
level=NOTSET
handlers=handlersmtp, handlerfile

[handler_handlersmtp]
class=handlers.SMTPHandler
level= INFO
formatter=formatter
args=(('localhost', 25),'localhost@localhost.com', ['abc@bca.com'],
                        'The log')


[handler_handlerfile]
class=handlers.RotatingFileHandler
level= INFO
formatter=formatter
backupCount=1440
args=('alogger.log')


The part in main file -xyz.py

Code: Select all
import logging
import logging.config
log = logging.config.fileConfig('/Users/Username/Desktop/logging.config')


I looked at the Python is logging/config.py module but couldn't follow why it was raising this. It's a pretty big file.
askance
 
Posts: 5
Joined: Fri Sep 20, 2013 10:25 pm

Re: Configuration file for logging

Postby ochichinyezaboombwa » Tue Oct 22, 2013 9:10 pm

It's not a weird but instead a very clear error message:
Code: Select all
TypeError: __init__() takes at most 7 arguments (23 given)

Apparently the class fileConfig requires less than you feed it to with your /Users/Username/Desktop/logging.config.
ochichinyezaboombwa
 
Posts: 200
Joined: Tue Jun 04, 2013 7:53 pm

Re: Configuration file for logging

Postby askance » Tue Oct 22, 2013 9:58 pm

I understand the message and that I need to supply <=7 args. But, I am following the documented literature and dunno why it's throwing this error. As far as I can tell, the config file has just the usual sections as per the guide.
askance
 
Posts: 5
Joined: Fri Sep 20, 2013 10:25 pm

Re: Configuration file for logging

Postby micseydel » Tue Oct 22, 2013 11:00 pm

I'm not sure that it'll help, but using modern documentation is usually a good idea: http://docs.python.org/2/library/logging.config.html

I haven't taken a closer look at this, but I will later assuming someone bumps this so it's unread for me later.
Join the #python-forum IRC channel on irc.freenode.net!
User avatar
micseydel
 
Posts: 1119
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA


Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 4 guests