root@zz test\]# cat a1.py #!/usr/bin/python # -\*- coding:utf-8 -\*- # # ithomer.net import logging import logging.handlers LOG_FILE = 'tst.log' handler = logging.handlers.RotatingFileHandler(LOG_FILE, maxBytes = 1024\*1024\*10, backupCount=5) fmt = '%(asctime)s - %(filename)s:%(lineno)s - %(name)s - %(levelname)s - %(message)s' formatter = logging.Formatter(fmt) handler.setFormatter(formatter) logger = logging.getLogger('tst') logger.addHandler(handler) logger.setLevel(logging.DEBUG) logger.info('info msg') logger.debug('debug msg') for i in range(1, 100000): logger.info(str(i)) \[root@zz test\]# date;stat tst.log Fri Dec 22 23:18:56 CST 2023 File: \`tst.log' Size: 4601678 Blocks: 8992 IO Block: 4096 regular file Device: 803h/2051d Inode: 948538 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2023-12-22 23:18:49.158997975 +0800 Modify: 2023-12-22 23:18:56.041999938 +0800 Change: 2023-12-22 23:18:56.041999938 +0800 \[root@zz test\]# date;stat tst.log Fri Dec 22 23:20:03 CST 2023 File: \`tst.log' Size: 8868541 Blocks: 17328 IO Block: 4096 regular file Device: 803h/2051d Inode: 948699 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2023-12-22 23:19:54.939999936 +0800 Modify: 2023-12-22 23:20:03.068999937 +0800 Change: 2023-12-22 23:20:03.068999937 +0800 \[root@zz test\]# stat tst.log.1 File: \`tst.log.1' Size: 52428765 Blocks: 102400 IO Block: 4096 regular file Device: 803h/2051d Inode: 948538 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2023-12-22 23:18:49.158997975 +0800 Modify: 2023-12-22 23:19:54.939999936 +0800 Change: 2023-12-22 23:19:54.939999936 +0800
相关推荐
真实的菜几秒前
消息队列处理模式:流式与批处理的艺术coder_lorraine1 分钟前
【Linux系列】Linux用户大揭秘:从“公寓住户”到“社区管理员”的奇幻之旅Bruce_Liuxiaowei2 分钟前
PHP文件包含漏洞详解:原理、利用与防御泽020211 分钟前
C++之STL--listYGGP15 分钟前
吃透 Golang 基础:数据结构之 Map盖世英雄酱5813616 分钟前
Java 内存管理技巧(新手必看集合篇)~plus~17 分钟前
Harmony核心:动态方法修补与.NET游戏Mod开发码农小灰18 分钟前
Java 8 Stream API 入门到实践详解步、步、为营23 分钟前
.NET 事件模式举例介绍cui_hao_nan26 分钟前
设计模式——模板方法