A high-performance Python log handler for VictoriaLogs.
release python CI/CD codecov license
victorialogs-handler is a high-performance Python log handler tailored for VictoriaLogs. It integrates seamlessly with Python’s native logging module, allowing you to stream log events to a VictoriaLogs instance with minimal configuration.
- Non-blocking: Logs are stored in a buffer and later processed in a background thread.
- Hybrid trigger: Log processing is triggered by a ticker and/or when a size threshold is reached.
- Batching: Multiple logs are combined into one request to the log server to minimize the amount of requests.
- Complete logs: All fields of a log record are transmitted including exceptions and
extrafields. - Highly customizable: The handler's behavior is highly customizable (see also Documentation)
The handler can be installed with PIP from PyPI:
pip install victorialogs-handler
Note
The script assumes that there is a VictoriaLogs server running
on the same system at the default URL: http://localhost:9428
Here is a quick example on how to use the handler in your Python script:
import logging from vlogs_handler import VictoriaLogsHandler # Create a custom logger with INFO level logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) # Add a handler for VictoriaLogs vlogs_handler = VictoriaLogsHandler() vlogs_handler.setLevel(logging.DEBUG) logger.addHandler(vlogs_handler) # Log example logger.info("This is an info message")
Please see the directory /examples for additional examples on how to use the handler.
The full documentation can be found here: Documentation.