logrotate for the Oracle Listener

When deploying a new database, one thing I usually do is to set up a logrotate configuration for the Oracle Listener log. The Oracle Listener logs every connection he makes and when using an Application Server to interface the database, this file can grow quite a bit. So we need to make sure that we properly rotate this log and compress the old logs.

To achieve this, I usually create the following configuration for logrotate:

$ cat /etc/logrotate.d/oracle-listener
/u01/app/oracle/product/10.2.0/db_1/network/log/listener.log {
weekly
copytruncate
rotate 4
compress
}

To get a quick overview of all the parameters, take a look at the following page: logrotate(8) – Linux man page. The listener log file is commonly named “listener.log” and is located in the $ORACLE_HOME/network/log/ folder. Note that the location of this log is configurable, so your mileage may vary (issue “lsnrctl status” to get the path of the logfile).

To test the script we can force logrotate to rotate the log even if the conditions (“weekly” in our case) do not match:

# logrotate -f /etc/logrotate.d/oracle-listener