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
相关推荐
ChaseDreamRunner10 分钟前
如何用 NSSM 把 Jar 做成 Windows 服务wang090711 分钟前
Linux性能优化之平均负载神の愛11 分钟前
java的Aop左左右右左右摇晃23 分钟前
ConcurrentHashMap ——put + get今夕资源网32 分钟前
零基础 Python 环境搭建工具 一键安装 Python 环境自动配置 升级 pip、setuptools、wheel啥咕啦呛35 分钟前
java打卡学习4:HashMap底层结构、扩容机制BieberChen38 分钟前
ubuntu定时执行脚本---crontab详细使用指南qq_2975746741 分钟前
K8s系列第十四篇:K8s 故障排查实战:常见故障定位与解决方法Flittly41 分钟前
【SpringAIAlibaba新手村系列】(3)ChatModel 与 ChatClient 的深度对比