On Sat, Mar 5, 2011 at 10:41 AM, Edwin <edwinja...@gmail.com> wrote:
> I'm getting a strange behaviour when setting up logging. Here's my
> logging configuration:
>
> LOGGING =
> {
>    'version': 1,
>    'disable_existing_loggers': True,
>    'formatters': {
>        'admin_configuration': {
>            'format': '%(asctime)s %(levelname)s %(category)s %
> (sub_category)s %(type_id)s %(message)s',
>            'datefmt': LOG_DATE_FORMAT,
>        },
>    },
>    'handlers': {
>        'admin_console': {
>            'level':'DEBUG',
>            'class':'logging.StreamHandler',
>            'formatter': 'admin_configuration'
>        },
>        'db': {
>            'level':'DEBUG',
>            'class':'apps.history.handlers.DatabaseHandler',
>            'formatter': 'admin_configuration'
>        },
>    },
>    'loggers': {
>        'db_logger': {
>            'handlers': [ 'admin_console', 'db' ],
>            'level': 'DEBUG',
>            'propagate': False,
>        },
>    }
> }
>
> I then created a Database log handler and the log record will be
> created using signals (e.g. on model save/delete) because I'm trying
> to keep track of model changes.  As you can see from my config, the
> logger has 2 handlers, 1 for DB and 1 for stdout (stream handler).
>
> I use the logger this way:
>
> logging.getLogger('db_logger').log(level, msg, extra=extras)
>
> where extras are extra attributes I'm passing to the logger.
>
> Now the weird thing is, when I change the order of 'handlers'
> definition under 'db_logger' to ['db', 'admin_console'], the logger
> raises this error:
> LogRecord instance has no attribute 'asctime'
>
> After checking the record instance, 'message' attribute is generated
> either, but all of my extra attributes are there.
> The same error happens if I remove 'admin_console' handler. The only
> way I can get the logger to work is that the handler must be in the
> original order:  'handlers': [ 'admin_console', 'db' ]
>
>
> Any idea why this is happening??

It's difficult to say. If I had to guess, I'd say there was something
unusual about your db logger. However, without seeing explicit stack
traces or sample code, that's about the best I can offer.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to