simple error log message in django

后端 未结 2 1784
南笙
南笙 2021-01-01 09:33

I\'ve got error emails setup via Django\'s logging mechanism in 1.3. It sends me a nice email when an error happens. However, when I log a simple error message it\'s being f

2条回答
  •  醉梦人生
    2021-01-01 09:50

    The Django Logging docs state:

    Of course, it isn't enough to just put logging calls into your code. You also need to configure the loggers, handlers, filters and formatters to ensure that logging output is output in a useful way.

    You need to tweak your settings in your logging.config() dictionary. That allows you to set out exactly what information you want and how to format.

    Cutting a small bit from the docs:

    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
        },
    

    Gives you a bit of an idea how you can influence the output, and the logging.config docs for python will fill out the available options.

提交回复
热议问题