How to configure a DatagramHandler for logging?

137 views
Skip to first unread message

Roy Smith

unread,
Jun 28, 2020, 9:18:34 PM6/28/20
to django...@googlegroups.com
Python 3.7.3
Django 2.2.13
Debian Linux

I'm trying to configure a DatagramHandler for logging.  My LOGGING config is:

    LOGGING = {
        'version': 1,
        'disable_existing_loggers': False,
        'handlers': {
            'file': {
                'level': 'DEBUG',
                'class': 'logging.FileHandler',
                'filename': os.path.join(LOG_DIR, 'django.log'),
            },
            'netcat': {
                'level': 'DEBUG',
                'class': 'logging.handlers.DatagramHandler',
                'host': 'xxxxx',
                'port': 23001,
            },
        },
        'loggers': {
            'django': {
                'handlers': ['file'],
                'level': 'DEBUG',
                'propagate': True,
            },
        },
    }

When django starts, I get:

AttributeError: module 'logging' has no attribute 'DatagramHandler'

Sure enough, if I look in.../lib/python3.7/logging/__init__.py, there is no DatagramHandler.  So what am I supposed to do?

I suspect this is more of a Python question than a Django question, but I figured I'd start here and work my way up :-)

Roy Smith

unread,
Jun 28, 2020, 9:22:15 PM6/28/20
to django...@googlegroups.com
Correction, the line that says 'logging.handlers.DatagramHandler', really reads 'logging.DatagramHandler' in the code I'm running. The logging.handlers.DatagramHandler was just something I tried to see what it would do.
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0AE03550-BE78-48A0-A42F-D5A05FF9D42D%40panix.com.

Roy Smith

unread,
Jun 28, 2020, 9:41:00 PM6/28/20
to django...@googlegroups.com
Oh, never mind.  It turns out  'logging.handlers.DatagramHandler' is exactly what you need, I just didn't get all the pieces wired up right.


On Jun 28, 2020, at 9:20 PM, Roy Smith <r...@panix.com> wrote:

 'logging.handlers.DatagramHandler',

Reply all
Reply to author
Forward
0 new messages