1 Basic Logging Tutorial 1.1 When to use logging 2 Events that are tracked can be handled in different ways. The simplest way of handling tracked events is to print them to the console. Another common way is to write them to a disk file. The default level is$_{WARNING}$ , which means that only events of this level and above will be tracked, unless the logging package is configured to do otherwise. The logging functions are named after the level or severity of the events they are used to track. The standard levels and their applicability are described below (in increasing order of severity): Logging provides a set of convenience functions for simple logging usage. These are debug() , info() , warning() , error() and critical() . To determine when to use logging, see the table below, which states, for each of a set of common tasks, the best tool to use for it. Logging is a means of tracking events that happen when some software runs. The software’s developer adds logging calls to their code to indicate that certain events have occurred. An event is described by a descriptive message which can optionally contain variable data (i.e. data that is potentially different for each occurrence of the event). Events also have an importance which the developer ascribes to the event; the importance can also be called the level or severity . Task you want to perform The best tool for the task Display console output for ordi- nary usage of a command line script or program print() Report events that occur during normal operation of a program (e.g. for status monitoring or fault investigation) logging.info() (or logging.debug() for very detailed output for diagnostic purposes) Issue a warning regarding a par- ticular runtime event warnings.warn() in library code if the issue is avoidable and the client application should be modified to eliminate the warning logging.warning() if there is nothing the client application can do about the situation, but the event should still be noted Report an error regarding a par- ticular runtime event Raise an exception Report suppression of an error without raising an exception (e.g. error handler in a long-running server process) logging.error() , logging.exception() or logging. critical() as appropriate for the specific error and application domain Level When it’s used 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 (e.g. ‘disk space low’). The software is still working as expected. 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.