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.