Logfile name format in logging

M

Muruga Raj

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?
 
D

Dejan Dimic

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?

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

Tim Pease

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?

The logging gem does not support this directly. You will need to
writer your own appender class as Dejan Dimic 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>

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
 
M

Muruga Raj

Tim said:
The logging gem does not support this directly. You will need to
writer your own appender class as Dejan Dimic 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>

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top