java显示数据一次滚动一次,如何在Java中将统计数据写入滚动文件

I would like to create rolling files that contains statistical data about my service.

for example, logging each request that contained parameter X with a certain result set.

I have to write these files to comply with other systems statistical data:

Roll the file every half an hour

Each file have to have column headers

I have to follow a strict file name convention such as tracking.display.1314116577.done

My service is written in Java.

Since I need to roll files, using loggers seems like a good direction so I have tried an approach where I would log the data using logback logger (my logger of choise), but the conventional rolling file appender cannot role the file every half an hour (or am i wrong?), cannot add column headers and has a strict naming convention of its own.

I have tried to write my own RollingPolicy, but can't find enough resources or examples of how it's done.

Can anyone show/refer me how to accomplish this?

If not, would you recommend a different approach?

Thank you!

解决方案

Yes, you can do it with a logback appender.

Take a look at TimeBasedRollingPolicy of RollingFileAppender you can easily roll the file each half hour.

To write the header you can extend RollingFileAppender and add the header based on your needs.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值