log4j日志切割原理

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

相关推荐
缘来的精彩2 分钟前
kotlin 多个fragment beginTransaction容器添加使用
android·开发语言·kotlin
安小牛4 分钟前
Kotlin 学习-集合
android·开发语言·学习·kotlin
小王努力学编程4 分钟前
【Linux网络编程】UDP Echo Server的实现
linux·运维·服务器·网络·c++·学习·udp
想睡hhh5 分钟前
Leetcode12 13——罗马数字与整数之间的转换
linux·运维·服务器
阿里云云原生8 分钟前
如何使用通义灵码玩转Linux - AI编程助手提升效率
linux
Peter_chq10 分钟前
selenium快速入门
linux·开发语言·chrome·python·selenium
AronTing12 分钟前
12- Java虚拟线程(Project Loom)深度解析:原理、实战与性能调优
java·后端·面试
双叶83615 分钟前
(51单片机)串口通讯(串口通讯教程)(串口接收发送教程)
c语言·开发语言·c++·单片机·嵌入式硬件·microsoft·51单片机
顾林海18 分钟前
深度解析LinkedHashSet工作原理
android·java·面试
创码小奇客23 分钟前
Java 对象变形记:BeanUtils 与 MapStruct 的高阶魔法实战
java·spring boot·trae