Django Logger - writing logs in different files

37 views Asked by At

These are the parameters I have inside my LOGGING in a Django REST Framework project. I have set logs everytime I shoot an email, and everytime I catch an error, I would like it to log into my error file and debug stuff into my debug.log file. However, I get error logs in both files, while I only get debug in my email debug.log file.

"handlers": {
            "invitation_email_info": {
            "level": "DEBUG",
            "class": "logging.FileHandler",
            "filename": "projectname/logs/invitation/.debug.log",
            "formatter": "verbose"
        },
        "invitation_email_error": {
            "level": "ERROR",
            "class": "logging.FileHandler",
            "filename": "projectname/logs/invitation/.error.log",
            "formatter": "verbose"
        },
    },
    "loggers": {
        "Invitation": {
            "handlers": ["invitation_email_info", "invitation_email_error"],
            "level": "DEBUG",
            "propagate": False,
        },

I tried playing around and was thinking if I should create more loggers, one for Invitation_Debug and one for Invitation_email. Please let me know. Thanks.

0

There are 0 answers