1 Database Troubleshooting
HiranChaudhuri edited this page 2026-03-13 08:26:54 +01:00

Database Troubleshooting

SQL Logging

If you try to understand what paperless-ngx is doing to your database, one good shot is to turn on SQL logging. With that you will see all the SQL commands paperless sends to the database.

In settings.py find the location where logging is configured. It will look similar to this:

"loggers": {
    "paperless": {"handlers": ["file_paperless"], "level": "DEBUG"},
    "paperless_mail": {"handlers": ["file_mail"], "level": "DEBUG"},
    "ocrmypdf": {"handlers": ["file_paperless"], "level": "INFO"},
    "celery": {"handlers": ["file_celery"], "level": "DEBUG"},
    "kombu": {"handlers": ["file_celery"], "level": "DEBUG"},
    "_granian": {"handlers": ["file_paperless"], "level": "DEBUG"},
    "granian.access": {"handlers": ["file_paperless"], "level": "DEBUG"},
},

Add a line like

"django.db.backends": {"handlers": ["console"], "level": "DEBUG"},

So the whole section would look like this:

"loggers": {
    "paperless": {"handlers": ["file_paperless"], "level": "DEBUG"},
    "paperless_mail": {"handlers": ["file_mail"], "level": "DEBUG"},
    "ocrmypdf": {"handlers": ["file_paperless"], "level": "INFO"},
    "celery": {"handlers": ["file_celery"], "level": "DEBUG"},
    "kombu": {"handlers": ["file_celery"], "level": "DEBUG"},
    "_granian": {"handlers": ["file_paperless"], "level": "DEBUG"},
    "granian.access": {"handlers": ["file_paperless"], "level": "DEBUG"},
    "django.db.backends": {"handlers": ["console"], "level": "DEBUG"},
},

Restart paperless-ngx and watch it's console output.