开发者

Using java.util.logging, is it possible to restart logs after a certain period of time?

开发者 https://www.devze.com 2022-12-30 08:58 出处:网络
I have some java code that will be running as an importer for data for a much larger project.The initial logging code was done with the java.util.logging classes, so I\'d like to keep it if possible,

I have some java code that will be running as an importer for data for a much larger project. The initial logging code was done with the java.util.logging classes, so I'd like to keep it if possible, but it seems to be a little i开发者_StackOverflownadequate now given he amount of data passing through the importer.

Often times in the system, the importer will get data that the main system doesn't have information for or doesn't match the system's data so it is ignored but a message is written to the log about what information was dropped and why it wasn't imported. The problem is that this tends to grow in size very quickly, so we'd like to be able to start a fresh log daily or weekly.

Does anybody have an idea if this can be done in the logging classes or would I have to switch to log4j or custom?

Thanks for any help!


I think you have to roll your own StreamHandler (at least as of Java 1.5 it didn't come with an implementation). Here is someone who did it.


You can use log4j and use the DatedFileAppender (distributed separately). This creates a single file per Date. I like it very much and use it everywhere where I implement log4j (even my Tomcat server logs through it!).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号