How it works...

The logging configuration consists of four parts: loggers, handlers, filters, and formatters. The following list describes them:

  • Loggers are entry points into the logging system. Each logger can have a log level: DEBUG, INFO, WARNING, ERROR, or CRITICAL. When a message is written to the logger, the log level of the message is compared with the logger's level. If it meets or exceeds the log level of the logger, it will be further processed by a handler. Otherwise, the message will be ignored.
  • Handlers are engines that define what happens to each message in the logger. They can be written to a console, sent by email to the administrator, saved to a log file, sent to the Sentry error-logging service, and so on. In our case, we set the include_html parameter for the mail_admins handler, as we want the full HTML with traceback and local variables for the error messages that happen in our Django project.
  • Filters provide additional control over the messages that are passed from the loggers to handlers. For example, in our case, the emails will only be sent when the DEBUG mode is set to false.
  • Formatters are used to define how to render a log message as a string. They are not used in this example; however, for more information about logging, you can refer to the official documentation at https://docs.djangoproject.com/en/2.1/topics/logging/.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.114.142