Support Logging setup Django logging

Django Logging

You can send Django logs to Loggly over syslog. This will send them from Django to a local rsyslog daemon which will forward them to Loggly. It assumes you use rsyslog 1.19 or higher in the standard directory, TCP over port 514, and you have sudo permissions. For alternatives, please see the Advanced Options section below.

Django Logging Setup

1. Configure syslog daemon

Run our automatic configure-linux script below to setup logging and send the Django logs to Loggly through your syslog daemon.

curl -O
sudo bash -a SUBDOMAIN -u USERNAME


  • SUBDOMAIN: your account subdomain that you created when you signed up for Loggly
  • USERNAME: your Loggly username

2. Configure rsyslog to forward Django logs to Loggly

Open your Django configuration file for rsyslog or create a new one:

sudo vim /etc/rsyslog.d/21-django.conf

Paste this configuration into the file then save it.

#provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514

#Add a tag for Django events
$template LogglyFormatDjango,"<%pri%>%protocol-version% %timestamp:::date-rfc3339% %HOSTNAME% %app-name% %procid% %msgid% [TOKEN@41058 tag=\"Django\"] %msg%\n"
local7.* ~ #discards the messages so they don't end up in /var/log/syslog


Then restart rsyslog so the changes take effect

sudo service rsyslog restart

3. Configure Django to send logs

Open file of your application.


Copy the following code in the file to configure your Django application to send logs to Loggly

   'version': 1,
   'disable_existing_loggers': False,
   'formatters': {
      'django': { 
         'format':'django: %(message)s',

   'handlers': {
      'logging.handlers.SysLogHandler': {
         'level': 'DEBUG',
         'class': 'logging.handlers.SysLogHandler',
         'facility': 'local7',
         'formatter': 'django',
         'address' : '/dev/log',

   'loggers': {
         'handlers': ['logging.handlers.SysLogHandler'],
         'propagate': True,
         'format':'django: %(message)s',
         'level': 'DEBUG',

4. Send A Test Event

Now call the defined logger in the Django files. In our case it is loggly_logs. Run your application with this code to send a test event to Loggly.

import logging
logger = logging.getLogger('loggly_logs')'Hi, Welcome to Loggly.')

5. Verify Events

Search Loggly for events with the syslog.appName as django over the past 20 minutes. It may take few minutes to index the event. If it doesn’t work, see the troubleshooting section below.


Advanced Django Logs Options

Django Logging Troubleshooting

If you don’t see any data show up in the verification step, then check for these common problems.

  • Wait a few minutes in case indexing needs to catch up
  • Check if you are using the same logger name as mentioned in the file.
  • Troubleshooting Rsyslog
  • Search or post your own questions around Django logging, Python logging, Django error logs, plus logging messages and default and custom logging configuration in the community forum.
Thanks for the feedback! We'll use it to improve our support documentation.