Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Logging: Change sender email address from root@localhost to something else

In my settings.py i have the following logging config. If there's an error i get an email from root@localhost. My problem is that i have several projects and want all error messages sent to the same email adress. But now its very annoying to identify on which site the error occured so i want to replace the senders email address from root@localhost to something like [email protected]. Is this possible or have i to create some virtual mailboxes?

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'mail_admins': {
            'level': 'DEBUG',
            'class': 'django.utils.log.AdminEmailHandler'
        },
    'logfile': {
        'class': 'logging.handlers.WatchedFileHandler',
        'filename': '/var/log/django/proj_name.log'
        },
    },
'loggers': {
    'django.request': {
        'handlers': ['mail_admins'],
        'level': 'DEBUG',
        'propagate': True,
        },
    'django': {
        'handlers': ['logfile'],
        'level': 'DEBUG',
        'propagate': False,
        },
    }
}
like image 452
Registered User Avatar asked Jan 24 '13 23:01

Registered User


1 Answers

mail_admins uses SERVER_EMAIL setting

like image 180
dzida Avatar answered Oct 30 '22 20:10

dzida