# Logfile name format in logging

**URL:** <https://www.ruby-forum.com/t/logfile-name-format-in-logging/156237>\
**Category:** Ruby\
**Created:** [December 23, 2008, 8:19am UTC](https://www.ruby-forum.com/t/logfile-name-format-in-logging/156237 "2008-12-23T08:19:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![murraj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f6c823/32.png) [@murraj](https://www.ruby-forum.com/u/murraj)\
**Post date:** [December 23, 2008, 8:19am UTC](https://www.ruby-forum.com/t/logfile-name-format-in-logging/156237/1 "2008-12-23T08:19:08Z")

</div>

Hi,

I am using the “logging” gem for logging.  
I used the “RollingFile” appender to rotate the log files.  
When the files are rotated they are saved with the sequential number  
extension.  
That is like develeopment.1.log, development.2.log etc.

Is there any way to add the timestamp for the rotated log file name such  
as development\_12232008.log etc?

---

<div class="post-metadata">

**Author:** ![murraj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f6c823/32.png) [@murraj](https://www.ruby-forum.com/u/murraj)\
**Post date:** [December 23, 2008, 9:30am UTC](https://www.ruby-forum.com/t/logfile-name-format-in-logging/156237/2 "2008-12-23T09:30:53Z")

</div>

On Dec 23, 8:10 am, Muruga R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> –  
> Posted viahttp://www.ruby-forum.com/.

You can write your own Logging::Appenders::RollingFileWithTimeStamp  
based od Logging::Appenders::RollingFile.

---

<div class="post-metadata">

**Author:** ![murraj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f6c823/32.png) [@murraj](https://www.ruby-forum.com/u/murraj)\
**Post date:** [December 24, 2008, 4:49am UTC](https://www.ruby-forum.com/t/logfile-name-format-in-logging/156237/3 "2008-12-24T04:49:12Z")

</div>

Tim P. wrote:

> On Dec 23, 2008, at 12:10 AM, Muruga R. wrote:
> 
> > as development\_12232008.log etc?  
> > The logging gem does not support this directly. You will need to  
> > writer your own appender class as Dejan D. mentioned in his message.
> 
> Take a look at the following sample. It should do what you want, but  
> it is thoroughly untested.
> 
> [http://gist.github.com/39362](http://gist.github.com/39362)
> 
> I recommend using a date format such as YYYY/MM/DD. This allows your  
> log files to be sorted chronologically when you list them either in a  
> file explorer or from the command line using ls.
> 
> Blessings,  
> TwP

Thank you so much Tim and Dimic.

I am working to extend the RollingFile Appender for timestamped file  
names.  
When i finish i will convey you

Thanks once again for your ideas

---

<div class="post-metadata">

**Author:** ![murraj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f6c823/32.png) [@murraj](https://www.ruby-forum.com/u/murraj)\
**Post date:** [December 23, 2008, 5:13pm UTC](https://www.ruby-forum.com/t/logfile-name-format-in-logging/156237/4 "2008-12-23T17:13:34Z")

</div>

On Dec 23, 2008, at 12:10 AM, Muruga R. wrote:

> as development\_12232008.log etc?  
> The logging gem does not support this directly. You will need to  
> writer your own appender class as Dejan D. mentioned in his message.

Take a look at the following sample. It should do what you want, but  
it is thoroughly untested.

[http://gist.github.com/39362](http://gist.github.com/39362)

I recommend using a date format such as YYYY/MM/DD. This allows your  
log files to be sorted chronologically when you list them either in a  
file explorer or from the command line using ls.

Blessings,  
TwP
