0

I have customized kafka server and the app is creating log files and configures log rotation. My problem is that I need to compress the rotation logs that were created.

I tried to create new log rotation file on /etc/logrotate.d with the following configuration:

/opt/kafka/logs/server.log.* {

  monthly

  compress

  dateext

  dateformat _%Y-%m-%d

  extension .tar.gz

  missingok

  ifempty

}

With this configuration I cannot compress my old files, and the message is: log does not need rotating (log has been already rotated).

Thanks for your help :-)

StanTastic
  • 810
  • 1
  • 7
  • 24
Rasa
  • 1
  • Perhaps https://unix.stackexchange.com/questions/15546/logrotate-log-does-not-need-rotating-why will help? Try to Google the error message first, to show you did some research prior to posting. – StanTastic Feb 02 '21 at 09:49

1 Answers1

0

Try with the following configs:

General logs files:

/var/log/kafka/*.log
{
    daily
    dateext
    dateformat _%Y-%m-%d-%s
    compress
    nodelaycompress
    nocopy
    nocopytruncate
    nocreate
    missingok
    notifempty
}

Logs generates by log4j

/var/log/kafka/*.log*[0-9][0-9]
{
    daily
    # remove after compressed
    rotate 0
    nodateext
    compress
    nodelaycompress
    nocopy
    nocopytruncate
    nocreate

    missingok
    notifempty
}

Change the frequency as you need

Federico Sierra
  • 3,499
  • 1
  • 18
  • 24