Bug 1113582 - Timestamp based target log file name configuration in logrotate
Summary: Timestamp based target log file name configuration in logrotate
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: logrotate
Version: 20
Hardware: All
OS: Solaris
unspecified
low
Target Milestone: ---
Assignee: Jan Kaluža
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-06-26 13:05 UTC by Holger King
Modified: 2015-06-29 21:20 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2015-06-29 21:20:31 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Example logrotate configuration to verify the behaviour regarding a time-based log file name creation after the rotation (640 bytes, text/plain)
2014-07-02 17:07 UTC, Holger King
no flags Details

Description Holger King 2014-06-26 13:05:02 UTC
Description of problem:
According to the "logrotate" manual page there do exist the following directives to influence the file name of the rotated log file:
- dateext
- dateformat
- dateyesterday

The problem: all directives focus on date settings. The timestamp and its format cannot be specified for the created target log file.

Especially, applications (e.g. Java, C++, etc.) that do rely on a special log file name have problems when using logrotate for rotating their logs.

As "logrotate" does allow a hourly-based rotation there should be a possibility to specify the target log file name on a timestamp-based format, too.

Version-Release number of selected component (if applicable):
3.8.7

How reproducible:
no possibility to set the timestamp format :(

Steps to Reproduce:
1. usage of logrotate 3.8.7
2. according to man page no possiblity to set timestamp based rotated log file names
3.

Actual results:
only date-based log file names are being created by logrotate (when using "hourly" a sequentially increased number is added at the end)

Expected results:
Introduction of additional directives like:
- timext
- timeformat

Additional info:
This might be more a feature request and not a bug report. In case where feature requests have to be entered anywhere else, please let me know.

Kind regards,
Holger

Comment 1 Jan Kaluža 2014-06-27 11:35:55 UTC
Hm, maybe you could try "dateformat -%s" to use timestamp.

Comment 2 Holger King 2014-07-02 17:04:46 UTC
Dear Jan Kaluza,

I have to disappoint you: neither "dateformat -%s" nor "dateformat %s" worked with the following "logrotate" configuration (see "fs" attachment)

Logrotate produced the following results when using:
(1) dateformat -%s -> fs-server.log-%s.gz
(2) dateformat %s -> fs-server.log%s.gz

Any more hints or did I configure something wrong?

Comment 3 Holger King 2014-07-02 17:07:37 UTC
Created attachment 914247 [details]
Example logrotate configuration to verify the behaviour regarding a time-based log file name creation after the rotation

Comment 4 Holger King 2014-07-09 15:53:13 UTC
Dear Jan Kaluža,

based on my last feedback - did you find any configuration mistakes on my side? Would be kind to verify and let me know :)

Kind regards,
Holger

Comment 5 Holger King 2014-07-16 16:28:58 UTC
Dear Jan Kaluža,

I'm really looking forward to reading from you again. Might be kind to give me a brief feedback :)

Kind regards,
Holger

Comment 6 Jan Kaluža 2014-07-17 05:50:48 UTC
does it literally create log files named like "fs-server.log-%s.gz"? Your config works for me when testing.

Can you please try running logrotate with "-v" argument to get verbose debug output and paste it here?

Comment 7 Holger King 2014-07-17 12:33:45 UTC
Dear Jan Kaluža,

interesting, that it works on your side.

We executed the "logrotate" binary using the verbose option "-v":

fs@si0vm997:/opt/wcms/fs/logrotate $ /opt/sfw/bin/logrotate -f -v -s /opt/wcms/fs/logrotate/fs.status /opt/wcms/fs/logrotate/fs_date
reading config file /opt/wcms/fs/logrotate/fs_date

Handling 1 logs

rotating pattern: /opt/wcms/fs/log/fs-server.log  forced from command line (96 rotations)
empty log files are not rotated, old logs are removed
considering log /opt/wcms/fs/log/fs-server.log
  log needs rotating
rotating log /opt/wcms/fs/log/fs-server.log, log->rotateCount is 96
Converted ' -%s' -> '-%s'
dateext suffix '-%s'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
glob finding old rotated logs failed
running prerotate script
copying /opt/wcms/fs/log/fs-server.log to /opt/wcms/fs/log/fs-server.log-%s
truncating /opt/wcms/fs/log/fs-server.log
compressing log with: /bin/gzip
running last action script
fs@si0vm997:/opt/wcms/fs/logrotate $

As you can see "logrotate" does not expand the "-%s" of the "dateformat" directive.

Does "%s" expand to a unix timestamp calculated since 01.01.1970 or is there a possibility to specify a custom format for time as "YYYYMMHHSS"?

Comment 8 Holger King 2014-07-30 09:17:03 UTC
Dear Jan Kaluža,

did my last post help you analysing/finding the problem? It seems as the dateext suffix is interpreted as pure text and not replaced.

Comment 9 Holger King 2014-08-14 11:35:43 UTC
Dear Jan Kaluža,

long time ago with no feedback. Is there any possibility to get any help here?

Kind regards,
Holger

Comment 10 Fedora End Of Life 2015-05-29 12:13:43 UTC
This message is a reminder that Fedora 20 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 20. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '20'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 20 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 11 Fedora End Of Life 2015-06-29 21:20:31 UTC
Fedora 20 changed to end-of-life (EOL) status on 2015-06-23. Fedora 20 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.