Skip to content

Django Logger

Andreï Basdereff edited this page Sep 27, 2024 · 3 revisions

Create an instance of the logger

import logging

logger = logging.getLogger(__name__)

Logging levels

Logging provides several levels of severity for log messages: *DEBUG: Detailed information, typically of interest only when diagnosing problems. *INFO: Confirmation that things are working as expected. *WARNING: An indication that something unexpected happened, or indicative of some problem in the near future. *ERROR: Due to a more serious problem, the software has not been able to perform some function. *CRITICAL: A serious error, indicating that the program itself may be unable to continue running.

logging.debug('This is a debug message')
logging.info('This is an info message')
logging.warning('This is a warning message')
logging.error('This is an error message')
logging.critical('This is a critical message')
Clone this wiki locally