logging not working with Django

737 views
Skip to first unread message

Alan

unread,
Apr 14, 2010, 1:25:05 PM4/14/10
to Django users
Hi there,

I am trying to setup logging in my setting.py.

All seemed to be working with below:

handler =
logging.handlers.TimedRotatingFileHandler(LOG_FILENAME, backupCount=1)

until I decided to make it:

handler = logging.handlers.TimedRotatingFileHandler(LOG_FILENAME,
backupCount=1, maxBytes = 1024)

Now I got this in my apache2/error_log:

[Wed Apr 14 18:22:04 2010] [error] [client ::1] Traceback (most recent
call last):
[Wed Apr 14 18:22:04 2010] [error] [client ::1] File "/sw/lib/
python2.6/site-packages/django/core/handlers/wsgi.py", line 230, in
__call__
[Wed Apr 14 18:22:04 2010] [error] [client ::1]
self.load_middleware()
[Wed Apr 14 18:22:04 2010] [error] [client ::1] File "/sw/lib/
python2.6/site-packages/django/core/handlers/base.py", line 33, in
load_middleware
[Wed Apr 14 18:22:04 2010] [error] [client ::1] for
middleware_path in settings.MIDDLEWARE_CLASSES:
[Wed Apr 14 18:22:04 2010] [error] [client ::1] File "/sw/lib/
python2.6/site-packages/django/utils/functional.py", line 269, in
__getattr__
[Wed Apr 14 18:22:04 2010] [error] [client ::1] self._setup()
[Wed Apr 14 18:22:04 2010] [error] [client ::1] File "/sw/lib/
python2.6/site-packages/django/conf/__init__.py", line 40, in _setup
[Wed Apr 14 18:22:04 2010] [error] [client ::1] self._wrapped =
Settings(settings_module)
[Wed Apr 14 18:22:04 2010] [error] [client ::1] File "/sw/lib/
python2.6/site-packages/django/conf/__init__.py", line 73, in __init__
[Wed Apr 14 18:22:04 2010] [error] [client ::1] mod =
importlib.import_module(self.SETTINGS_MODULE)
[Wed Apr 14 18:22:04 2010] [error] [client ::1] File "/sw/lib/
python2.6/site-packages/django/utils/importlib.py", line 35, in
import_module
[Wed Apr 14 18:22:04 2010] [error] [client ::1] __import__(name)
[Wed Apr 14 18:22:04 2010] [error] [client ::1] File "/Users/alan/
workspace/webapps/settings.py", line 21, in <module>
[Wed Apr 14 18:22:04 2010] [error] [client ::1] handler =
logging.handlers.TimedRotatingFileHandler(LOG_FILENAME, backupCount=1,
maxBytes = 1024)
[Wed Apr 14 18:22:04 2010] [error] [client ::1] TypeError: __init__()
got an unexpected keyword argument 'maxBytes'


Testing the logging via ipython and all works fine.

Any help would be very appreciated.

Many thanks in advance,

Alan

Rolando Espinoza La Fuente

unread,
Apr 14, 2010, 2:07:09 PM4/14/10
to django...@googlegroups.com
On Wed, Apr 14, 2010 at 1:25 PM, Alan <alanw...@gmail.com> wrote:
[SNIP]

> handler = logging.handlers.TimedRotatingFileHandler(LOG_FILENAME,
> backupCount=1, maxBytes = 1024)

That handler doesn't have maxBytes keyword argument
http://docs.python.org/library/logging.html#timedrotatingfilehandler

~Rolando

Alan

unread,
Apr 15, 2010, 2:43:32 AM4/15/10
to Django users
Many thanks Rolando,

I can't believe I calling the wrong function...

Fixed and working now.

Cheers,
Alan

On 14 Apr, 19:07, Rolando Espinoza La Fuente <dark...@gmail.com>
wrote:

Reply all
Reply to author
Forward
0 new messages