https://github.com/easypost/syslog-rfc5424-formatter
Python logging formatter for emitting RFC5424 Syslog messages
https://github.com/easypost/syslog-rfc5424-formatter
Last synced: 6 months ago
JSON representation
Python logging formatter for emitting RFC5424 Syslog messages
- Host: GitHub
- URL: https://github.com/easypost/syslog-rfc5424-formatter
- Owner: EasyPost
- License: isc
- Created: 2016-03-23T22:38:31.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2025-05-20T01:46:24.000Z (8 months ago)
- Last Synced: 2025-06-09T09:29:23.560Z (8 months ago)
- Language: Python
- Size: 44.9 KB
- Stars: 16
- Watchers: 51
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE.txt
Awesome Lists containing this project
README
This module implements a python `logging` formatter which produces well-formed RFC5424-compatible Syslog messages to a given socket.
[](https://github.com/EasyPost/syslog-rfc5424-formatter/actions?query=workflow%3ACI)
[](https://badge.fury.io/py/syslog-rfc5424-formatter)
[](https://syslog-rfc5424-formatter.readthedocs.io/en/latest/?badge=latest)
## Usage
If you're configuring your loggers from code, you should use this formatter as below:
```python
import logging
import logging.handlers
from syslog_rfc5424_formatter import RFC5424Formatter
def set_up_logging():
h = logging.handlers.SysLogHandler('/path/to/syslog_socket')
h.setFormatter(RFC5424Formatter())
logging.getLogger('').addHandler(h)
```
If you're using a more modern combination of a JSON/YAML config file and `logging.config.dictConfig`, your config file should look like the following (assuming YAML concrete syntax):
```yaml
formatters:
syslog:
(): syslog_rfc5424_formatter.RFC5424Formatter
handlers:
syslog:
formatter: syslog
class: logging.handlers.SysLogHandler
address: "/path/to/syslog/socket"
facility: "ext://logging.handlers.SysLogHandler.LOG_USER"
root:
level: INFO
handlers:
- syslog
```
## License
This work is licensed under the ISC license, the text of which can be found at [LICENSE.txt](LICENSE.txt).