Discussion:
Rolling File Appender provided by Log4Net
Shaily Goel
2005-06-21 05:06:59 UTC
Permalink
We are planning to use Rolling File Appender provided by Log4net.

Our requirements are like below:

1. Rolling File Appender should be able to log the messages into a
local file with an extension of .log
2. It should write the message in xml format in local file.
3. It should be able to roll log files based on either size or date.
When the current log file reaches a particular size/date, a new log file
is rolled into its place.
4. The old log file should be stored in a compressed format until the
maximum number of log files is reached, causing the oldest log file to
be deleted.


I found that all my above requirements are met by Rolling File Appender
provided by log4net except that "The old log file should be stored in a
compressed format ".

I want to know whether Rolling File appender internally store all old
log files in compressed format??If not, how can we achieve this ?


Thanks
Shaily
Ron Grabowski
2005-06-21 13:04:38 UTC
Permalink
I don't think compressing files and complex file maintenance falls
within the scope of log4net.

What happens when the log file reaches 900mb in size? Even on a fast
machine, compressing such a large file may cause a slow down. Perhaps
you could have a second process or script run every day to compress and
move log files around according to your requirements.

You may be able to extend RollingFileAppender to make it do what you
want too.
Post by Shaily Goel
We are planning to use Rolling File Appender provided by Log4net.
1. Rolling File Appender should be able to log the messages into a
local file with an extension of .log
2. It should write the message in xml format in local file.
3. It should be able to roll log files based on either size or date.
When the current log file reaches a particular size/date, a new log file
is rolled into its place.
4. The old log file should be stored in a compressed format until the
maximum number of log files is reached, causing the oldest log file to
be deleted.
I found that all my above requirements are met by Rolling File
Appender
provided by log4net except that "The old log file should be stored in a
compressed format ".
I want to know whether Rolling File appender internally store all old
log files in compressed format??If not, how can we achieve this ?
Thanks
Shaily
Nicko Cadell
2005-06-21 16:44:13 UTC
Permalink
If you need to create a custom appender that compresses the archive
files you will need to create a new assembly with a copy of the
RollingFileAppender code in it. The RollXXX methods are used to roll the
old log file out of the way. These all call into the RollFile method, so
you may be able to extend the appender at that point. The appender
currently just uses System.IO.File.Move to roll the file.

You can find compression libraries for .net which will allow you to zip
the old files. As zipping up the file may be a slow operation I suggest
that you move the file to a temporary name and then compress it on a
separate thread.

Cheers,
Nicko
-----Original Message-----
Sent: 21 June 2005 06:07
Subject: Rolling File Appender provided by Log4Net
We are planning to use Rolling File Appender provided by Log4net.
1. Rolling File Appender should be able to log the messages
into a local file with an extension of .log
2. It should write the message in xml format in local file.
3. It should be able to roll log files based on either size
or date. When the current log file reaches a particular
size/date, a new log file is rolled into its place.
4. The old log file should be stored in a compressed format
until the maximum number of log files is reached, causing the
oldest log file to be deleted.
I found that all my above requirements are met by Rolling
File Appender provided by log4net except that "The old log
file should be stored in a compressed format ".
I want to know whether Rolling File appender internally store
all old log files in compressed format??If not, how can we
achieve this ?
Thanks
Shaily
Loading...