In this short blog post I will write about a new feature introduced with Oracle 19c. Starting with this release the plain-text listener log located in the diagnostic directory are rotated.
Table of Contents
With the release of the Automatic Diagnostic Respository (ADR) a XML version of the listener log was introduced. The listener log (log.xml) was rotated when the file size threshold of 10 MB (< 19c) was reached. Unfortunately the plain-text listener log was not considered for rotation.
But with Oracle 19c two new parameters were introduced, which can be configured for a listener in the listener.ora file. This feature is listed as Network Log File Segmentation in the Net Services Administrator’s Guide.
This new feature has also an impact on the XML version of the listener logfiles.
To configure the following parameters, you have to edit the listener.ora using an editor of your choice. After changing the parameters, a restart of the listener is required.
$> lsnrctl stop $> lsnrctl start
The parameter LOG_FILE_NUM_<Listener> defines the maximum number of kept logfiles. There is no default value defined, which results in an indefinitely number of logfiles.
LOG_FILE_NUM_LISTENER = 3
The parameter LOG_FILE_SIZE_<Listener> controls the maximum file size of a listener logfile in MB. Per default the logfile can increased until 300 MB.
LOG_FILE_SIZE_LISTENER = 2
The defined file size refers to the XML logfile. There is a one to one connection between the XML and the plain-text logfiles. The file size of the plain-text logfile is smaller than the file size of the XML version.
To test the log rotation you have to connect to the database using the Listener. You can use a simple shell script and start it several times.
$> vi connect.sh #!/bin/bash while ( true ); do sqlplus -S -L system/manager@localhost:1521/DB1 << EOF SELECT * FROM dual; EXIT; EOF done $> chmod +x connect.sh $> ./connect.sh > /dev/null & $> ./connect.sh > /dev/null & $> ./connect.sh > /dev/null & $> ...
You can see a connection between the XML and plain-text logfiles. Please have a look at the file sizes. After the XML logfile reaches the defined limit, both logfiles rotate.
$> cd $ORACLE_BASE/diag/tnslsnr/*/listener $> ls -ltrah alert/* -rw-r----- 1 oracle oinstall 2,1M 11. Nov 18:57 alert/log_7.xml -rw-r----- 1 oracle oinstall 2,1M 11. Nov 18:59 alert/log_8.xml -rw-r----- 1 oracle oinstall 2,1M 11. Nov 19:01 alert/log_9.xml -rw-r----- 1 oracle oinstall 250K 11. Nov 19:07 alert/log.xml $> ls -ltrah trace/* -rw-r----- 1 oracle oinstall 1,2M 11. Nov 18:57 trace/listener_7.log -rw-r----- 1 oracle oinstall 1,2M 11. Nov 18:59 trace/listener_8.log -rw-r----- 1 oracle oinstall 1,2M 11. Nov 19:01 trace/listener_9.log -rw-r----- 1 oracle oinstall 137K 11. Nov 19:08 trace/listener.log
Old logfiles are deleted after a log rotation occured.