Skip to content

Logging

This document explains how to configure logging for the paddleocr Python package. The paddleocr package uses a different logging system than training scripts, and this document does not cover training-script logging configuration.

PaddleOCR has built a centralized logging system based on Python's logging standard library. In other words, PaddleOCR uses a single logger, which can be accessed and configured via paddleocr.logger.

By default, the logging level in PaddleOCR is set to ERROR, meaning that log messages will only be output if their level is ERROR or higher (e.g., CRITICAL). PaddleOCR also configures a StreamHandler for this logger, which outputs logs to the standard error stream, and sets the logger's propagate attribute to False to prevent log messages from being passed to its parent logger.

If you wish to disable PaddleOCR's automatic logging configuration behavior, you can set the environment variable DISABLE_AUTO_LOGGING_CONFIG to 1. In this case, PaddleOCR will not perform any additional configuration of the logger.

For more flexible customization of logging behavior, refer to the relevant documentation of the logging standard library. Below is an example of writing logs to a file:

import logging
from paddleocr import logger

# Write logs to the file `paddleocr.log`
fh = logging.FileHandler("paddleocr.log")
logger.addHandler(fh)

Please note that other libraries that PaddleOCR depends on (such as PaddleX) have their own independent logging systems, and the above configuration will not affect the log output of these libraries.

Comments