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 :-)

1
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.