logrotate create one compressed archive from log files with different file names

I have a log folder under under /var/USER/mylogs and there on a daily basis log files in format "DATE-mylogile.log". DATE is formatted as "%d-%m-%Y".

So in my folder i have for example these log files:


Now i want to use logrotate to rotate the logs. My test-Configuration looks like this:

/var/USER/mylogs/*.log {
rotate 4
dateformat -%d-%m-%Y

But when logrotate runs it creates and gz-Archive for every single log file like:


But i want that logrotate creates weekly one gz-Archive which includes all the single log files from the week, so that there is only one gz-Archive like:


But there i’m stuck – so is it possible and how can i do this?

Asked By: Opa114


After a little bit more of research i found a post serverfault where the answer is given.

So it is not possible to rotate logs with time/date in the filename. logrotate is designed to use a log file which is everytime the same and the application writes on this single log file.

Answer from linked serverfault post:

"If you’re already creating the files with the date in the name,
logrotate isn’t the answer; it is based around the idea of the
application always writing to the same log file (e.g.
/var/log/app/output.log), and then logrotate takes care of
renaming/compressing the files and telling the app to re-open the
original target file again."

Answered By: Opa114
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.