# Log4r housekeeping

**URL:** <https://www.ruby-forum.com/t/log4r-housekeeping/135586>\
**Category:** Ruby\
**Created:** [April 23, 2008, 11:41am UTC](https://www.ruby-forum.com/t/log4r-housekeeping/135586 "2008-04-23T11:41:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Col\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/dec6dc/32.png) [@Col\_W](https://www.ruby-forum.com/u/Col_W)\
**Post date:** [April 23, 2008, 11:41am UTC](https://www.ruby-forum.com/t/log4r-housekeeping/135586/1 "2008-04-23T11:41:20Z")

</div>

Can I get log4r to change te log filename each day so that it is more  
easily housekept?

---

<div class="post-metadata">

**Author:** ![Col\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/dec6dc/32.png) [@Col\_W](https://www.ruby-forum.com/u/Col_W)\
**Post date:** [April 23, 2008, 4:15pm UTC](https://www.ruby-forum.com/t/log4r-housekeeping/135586/2 "2008-04-23T16:15:17Z")

</div>

On Apr 23, 2008, at 3:40 AM, Col W. wrote:

> Can I get log4r to change te log filename each day so that it is more  
> easily housekept?

I do believe log4r has a rolling file appender that will perform date/  
size based rolling of your log files. This will not alter the basename  
of the log file, just increment a counter …

basename.1.log  
basename.2.log  
etc.

Changing the basename is something you would have to do  
programatically from your own code. I do not think log4r supports that.

Blessings,  
TwP

---

<div class="post-metadata">

**Author:** ![Col\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/dec6dc/32.png) [@Col\_W](https://www.ruby-forum.com/u/Col_W)\
**Post date:** [May 5, 2008, 10:01pm UTC](https://www.ruby-forum.com/t/log4r-housekeeping/135586/3 "2008-05-05T22:01:12Z")

</div>

On 23 Apr., 11:36, Col W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Can I getlog4rto change te log filename each day so that it is more  
> easily housekept?

Hi Col,  
of course you can. Pls use the outputter DateFileOutputter.  
Have a look at the files in gems’ example directory:  
/install\_dir/ruby/lib/ruby/gems/1.8/gems/log4r-1.0.5/examples:  
yaml.rb & log4r\_yaml.yaml.

You can change the logfile name each year or month or day or hour or  
minute …

Cheers

Andreas
