14.5. Logging Handlers¶
In addition to the base Handler class, many useful subclasses are provided:
StreamHandlerinstances send messages to streams (file-like objects).
FileHandlerinstances send messages to disk files.
BaseRotatingHandleris the base class for handlers that rotate log files at a certain point. It is not meant to be instantiated directly. Instead, use
RotatingFileHandlerinstances send messages to disk files, with support for maximum log file sizes and log file rotation.
TimedRotatingFileHandlerinstances send messages to disk files, rotating the log file at certain timed intervals.
SocketHandlerinstances send messages to TCP/IP sockets. Since 3.4, Unix domain sockets are also supported.
DatagramHandlerinstances send messages to UDP sockets. Since 3.4, Unix domain sockets are also supported.
SMTPHandlerinstances send messages to a designated email address.
SysLogHandlerinstances send messages to a Unix syslog daemon, possibly on a remote machine.
NTEventLogHandlerinstances send messages to a Windows NT/2000/XP event log.
MemoryHandlerinstances send messages to a buffer in memory, which is flushed whenever specific criteria are met.
HTTPHandlerinstances send messages to an HTTP server using either GET or POST semantics.
WatchedFileHandlerinstances watch the file they are logging to. If the file changes, it is closed and reopened using the file name. This handler is only useful on Unix-like systems; Windows does not support the underlying mechanism used.
QueueHandlerinstances send messages to a queue, such as those implemented in the queue or multiprocessing modules.
NullHandlerinstances do nothing with error messages. They are used by library developers who want to use logging, but want to avoid the 'No handlers could be found for logger XXX' message which can be displayed if the library user has not configured logging. See Configuring Logging for a Library for more information.