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

相关推荐
卓怡学长7 分钟前
m280本科生导师指导平台
java·数据库·spring·tomcat·maven·intellij-idea
python猿8 分钟前
打卡Python王者归来--第30天
开发语言·python
qq_334903159 分钟前
嵌入式C++驱动开发
开发语言·c++·算法
阿贵---20 分钟前
C++代码规范化工具
开发语言·c++·算法
JiMoKuangXiangQu22 分钟前
Linux 锁 (4) - seqlock
linux·seqlock
暮冬-  Gentle°28 分钟前
自定义内存检测工具
开发语言·c++·算法
一直都在57228 分钟前
Java死锁
java·开发语言
娇娇yyyyyy31 分钟前
QT编程(15): Qt 按键事件和定时器事件
开发语言·qt
xlp666hub39 分钟前
如果操作GPIO可能导致休眠,那么同步机制绝不能采用spinlock
linux·面试
2501_945424801 小时前
C++编译期矩阵运算
开发语言·c++·算法