Skip to main content

Overview

This module provides an additional log handler for Python’s standard logging package (PEP 282). This handler will write a log entries to a set of files, which switches from one file to the next when the current file reaches a certain size. Multiple processes can write to the log file concurrently.

Details

The ConcurrentRotatingFileHandler class is a drop-in replacement for Python’s standard log handler RotatingFileHandler. This module uses file locking so that multiple processes can concurrently log to a single file without dropping or clobbering log records. This module provides a file rotation scheme like RotatingFileHanler, except that extra care is taken to ensure that logs can be safely rotated before the rotation process is started. (This module works around the file rename issue with RotatingFileHandler on Windows, where a rotation failure means that all subsequent logs are lost).

This module’s attempts to preserve log records at all cost. This means that log files will grow larger than the specified maximum (rotation) size. So if disk space is tight, you may want to stick with RotatingFileHandler, which will strictly adhere to the maximum file size.

Installation

Use the following command to install this package:

easy_install ConcurrentLogHandler

Simple example

Here is a example demonstrating how to use this module:

from logging import getLogger, INFO
from cloghandler import ConcurrentRotatingFileHandler
import os

log = getLogger()
# Use an absolute path to prevent file rotation trouble.
logfile = os.path.abspath("mylogfile.log")
# Rotate log after reaching 512K, keep 5 old copies.
rotateHandler = ConcurrentRotatingFileHandler(logfile, "a", 512*1024, 5)
log.addHandler(rotateHandler)
log.setLevel(INFO)

log.info("Here is a very exciting log message, just for you")

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ConcurrentLogHandler-0.7.3.tar.gz (18.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ConcurrentLogHandler-0.7.3-py2.5.egg (23.3 kB view details)

Uploaded Egg

ConcurrentLogHandler-0.7.3-py2.4.egg (23.4 kB view details)

Uploaded Egg

File details

Details for the file ConcurrentLogHandler-0.7.3.tar.gz.

File metadata

File hashes

Hashes for ConcurrentLogHandler-0.7.3.tar.gz
Algorithm Hash digest
SHA256 45d94886a92cf6c49259a6bb6fe767255431960aaf3455c098aaebe35dd85fff
MD5 a0a778fbaf4bd97c567cef71dc221e84
BLAKE2b-256 23a232b33dd0422eee473aa55e21762fa4c2774ac7a2f31154884e2df5791b0f

See more details on using hashes here.

File details

Details for the file ConcurrentLogHandler-0.7.3-py2.5.egg.

File metadata

File hashes

Hashes for ConcurrentLogHandler-0.7.3-py2.5.egg
Algorithm Hash digest
SHA256 249359ea9cf44b5587b2a3fffa7b180ad5dbbf81d7d96682094600ac758bc32f
MD5 2f569f4b47dd4065f9e5918b8066ce8d
BLAKE2b-256 44bc7c6f29f14af29530fa957787e1d2c24204dd9a286ce6c7e457c9550adfb2

See more details on using hashes here.

File details

Details for the file ConcurrentLogHandler-0.7.3-py2.4.egg.

File metadata

File hashes

Hashes for ConcurrentLogHandler-0.7.3-py2.4.egg
Algorithm Hash digest
SHA256 c400b7d914038818a38f605d6c42b6b738b8dc5cea8cb2fadebf38a7aa55d451
MD5 21cc5c7a7056d4e71f240069f64a6253
BLAKE2b-256 092149e4b532f16d153100143d5d72d71733e03b8ec8c6d936b6e16211660647

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page