tags:

views:

40

answers:

2

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 inadequate 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!

A: 

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!).

Daniel
+1  A: 

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.

Yishai
Thanks for the link, it looks promising and hopefully it will cause a minimum change in the code since all the class loggers grab the same handler.
Fry
+1 This is the way to go if you want the JDK logger.
Romain Hippeau
With a couple modifications, it works perfectly! Great link, and thanks!
Fry