Debian – way to have past logs for 1-2 years in dpkg

debiandpkglogs

All logs of dpkg are saved at /var/log/dpkg . The thing is if you are on Debian testing or/and Unstable/Sid the churn of packages are going to be much more than in a stable release. Now while in a stable release the churn is not so much and 7-8 log files should be in a position to serve . But in testing this simply proves to be too little.

For instance at my own end –

┌─[shirish@debian] - [~] - [10114]
└─[$] zgrep " install " /var/log/dpkg.log.8.gz | tail -1

2016-05-31 12:26:29 install gnuplot-qt:amd64 <none> 4.6.6-3

Now while this is somewhat useful, if I want to go back till a year, all of that info. is lost.

How can I prevent it from happening in the future ?

It would be better if the change were only limited to dpkg logs rather than all the logs.

Best Answer

You edit the file /etc/logrotate.d/dpkg, there should be a section there similar to this :

/var/log/dpkg.log {
        monthly
        rotate 12
        compress
        delaycompress
        missingok
        notifempty
        create 644 root root
}

You change the rotate 12 to rotate 24 to keep 2 years of logs, or rotate 36 to keep 3 years of logs.

Related Question