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

相关推荐
hweiyu0014 分钟前
Linux 命令:split
linux·运维·服务器
田野追逐星光19 分钟前
STL的容器vector的模拟实现
开发语言·c++
马猴烧酒.37 分钟前
【JAVA数据传输】Java 数据传输与转换详解笔记
java·数据库·笔记·tomcat·mybatis
爱编码的傅同学39 分钟前
【常见锁的概念】死锁的产生与避免
java·开发语言
lihe75841 分钟前
每天凌晨3点自动同步UBUNTU源
linux·运维·ubuntu·本地源
Tansmjs1 小时前
实时数据可视化库
开发语言·c++·算法
添砖java‘’1 小时前
线程的互斥与同步
linux·c++·操作系统·线程·信息与通信
我什么都学不会1 小时前
Python练习作业3
开发语言·python
rabbit_pro1 小时前
SpringBoot3使用PostGis+GeoTools整合MybatisPlus
java·spring
2401_838472511 小时前
C++模拟器开发实践
开发语言·c++·算法