I have a swing web sevice client. Am using Log4j for logging with RollingFileAppender. The log files that are generated are taking up a lot of disk space. Is there a configuration property in Log4j that allows the rolled over file to be compressed or is it possible to write compressed log files.
Kasi Viswan wrote:Is there a configuration property in Log4j that allows the rolled over file to be compressed or is it possible to write compressed log files.
No, there isn't. You could write your own subclass of that appender which zips a log file after closing. Or you could do what I do, which is to have a scheduled job which zips log files which are over a week old and deletes zip files which are over a year old. Choose your own intervals, of course, but I read log files often enough, and having to unzip them first is tedious, that's why I keep them unzipped for a week.
Joined: Sep 27, 2008
Thanks for the reply Paul, I will only be able to use the first option you suggested as in my case the log files will grow huge in few hours depending on the number of threads and the data processed, so i won't even be able to set a predefined time to compress the logs.
As I understand i have to write a AppenderClass extending RollingFileAppender, which method should i override, is it the close(). Is this where i should I should compress the log file that is closed, How do i get handle to the file that is being closed. Please advice.
I have one more question on Log4j,
I create more than one log file in my application, how do i relinquish control from the log files generated after a data run while still having my Swing client running.