AI Briefing
KO

Two Scoops Study Session #18

·2017.11.15 00:00

Key point

We studied Django's **logging** and **signals** together, and also organized tips on operating logs and metrics.

Details

This time, we studied Two Scoops of Django chapters 27 and 28. The topics were who logging is a tool for, and when to use signals and when to avoid them.

Diagnostic logs are used to track the application's behavior and error situations, while audit logs are used to record user actions and business analytics. Logs are useful for reproducing problems and finding root causes, and they leave far more context than simple print statements.

print is no better than logging except perhaps for showing help messages in command-line applications. In contrast, a log record retains information such as filename, path, function, and line number together, which is advantageous for debugging.

The log level can be adjusted with logging.Logger.setLevel(), and can also be disabled with logging.Logger.disabled = True. Events occurring in built-in modules can also be gathered into the application's log stream through the root logger.

Configuration methods were organized into three main types.

  • INI files: an approach that uses logging.config.listen() together to reflect configuration changes while running
  • dict/JSON files: manages configuration without modifying code, and from Python 2.6 onward can also be loaded with the standard json module
  • Code: allows the most powerful control over all settings, but requires modifying the source

The in-depth presentation also covered the flow of logs and metrics. It introduced a structure where the application creates logs, forwards them via fluentd, stores and organizes them in Elasticsearch, and displays them with Kibana.

Practical standards for operating logs were also organized.

  • Keep logs by default
  • Switch to metrics when there get to be too many
  • Prefer formats that are easy to parse and document, such as key, value form
  • Don't just accumulate logs locally—manage them with logrotate

A participant felt that logging is as unfamiliar as testing, but is a tool they need to get used to for future development. They also mentioned that through the study group, they were able to learn not only about Django but also about the attitudes and team culture of senior developers, and shared plans to apply logging directly in upcoming projects.

This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.

Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.