Logger
Print statement generally does not work in production so, to get message we use logger
- Troubleshooting made easier
- Runtime information in production
- https://www.youtube.com/watch?v=ziegOuE7M4A&list=PL2NFhrDSOxgXXUMIGOs8lNe2B-f4pXOX-&index=4
What is Logging?
How Logging Works in Django
- Django comes with
Python's built-in logging module
to leverage system logging.- Loggers
- Handlers
- Filters
- Formatters
Loggers
- Loggers are basically the entry point of the logging system.
- If the log-level is same or exceeds the log-level of the logger, the message is sent to the handler for further processing.
DEBUG: 10 --> Low-level system information
INFO: 20 --> General system information
WARNING: 30 --> Minor problems related information
ERROR/EXCEPTION: 40 --> Major problems related information
CRITICAL: 50 --> Critical problems related information
dblogger.debug("Test Debug")
dblogger.info("Test Info")
dblogger.warning("Test Warning")
dblogger.warn("Test Warn") # Depricated
dblogger.error("Test Error")
dblogger.exception("Test Exception")
dblogger.critical("Test Critical")
Handlers
Handlers basically determine what happens to each message in a logger eg: write to a file or console.
[Read More]