> For the complete documentation index, see [llms.txt](https://huataihuang.gitbook.io/cloud-atlas-draft/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://huataihuang.gitbook.io/cloud-atlas-draft/develop/python/log/logging_with_log_rotation_and_compression.md).

# 在python日志中使用轮转和压缩

在[Python简单日志](https://github.com/huataihuang/cloud-atlas-draft/tree/6f3204fffc11cf006abd394631e2598d98b415c3/develop/python/log/logging/README.md)中讨论了如何处理日志的方法，但是大量的日志会消耗存储资源，需要有一个良好的日志轮转和压缩功能。

通常在操作系统级别会采用通用的logrotate工具来实现日志轮转和压缩，但是对于python来说，也有丰富的日志库可以实现日志轮转和压缩功能。

## 参考

* [Python, want logging with log rotation and compression](https://stackoverflow.com/questions/8467978/python-want-logging-with-log-rotation-and-compression)
