Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Python's logging module thread safe?

Tags:

python

If you call the same logging handler from two different python threads, is there a need for locking?

like image 561
Rhubarb Avatar asked Jun 04 '10 12:06

Rhubarb


People also ask

Does Python logging module use log4j?

The inbuilt logging module in python requires some handful of lines of code to configure log4j-like features viz - file appender, file rotation based on both time & size. For one-liner implementation of the features in your code, you can use the package autopylogger .

Is Python logging blocking?

The built-in python logger is I/O blocking. This means that using the built-in logging module will interfere with your asynchronous application performance. aiologger aims to be the standard Asynchronous non-blocking logging for python and asyncio.

What is logging module in Python?

Python comes with a logging module in the standard library that provides a flexible framework for emitting log messages from Python programs. This module is widely used by libraries and is the first go-to point for most developers when it comes to logging.

What is logger getLogger in Python?

The getLogger() function accepts a single argument - the logger's name. It returns a reference to a logger instance with the specified name if provided, or root if not. Multiple calls to getLogger() with the same name will return a reference to the same logger object.


1 Answers

The logging module is thread-safe; it handles the locking for you. See the docs.

like image 165
unutbu Avatar answered Sep 18 '22 17:09

unutbu