• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Log4j - Compress Log Files

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Here is my current log4j configuration:



Any help is much appreciated.

Thanks
Kasi
 
Sheriff
Posts: 28371
99
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Kasi Viswan
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Thanks
Kasi
 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kasi,

Can you please elaborate more, what is your actual need..

Tahnks,
Tanzy.
 
They gave me pumpkin ice cream. It was not pumpkin pie ice cream. Wiping my tongue on this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic