1、关闭监听日志记录
lsnrctl set log_status off
2、备份 listener.log
mv listener.log listener.log_20210524
3、清空日志
echo /dev/null > listener.log
4、开启监听日志记录
lsnrctl set log_status on
--操作过程
[oracle@bsdb trace]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 24-MAY-2021 18:30:38
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=bsdb)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 21-MAR-2020 15:34:49
Uptime 429 days 2 hr. 55 min. 48 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /home/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /home/app/oracle/diag/tnslsnr/bsdb/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=bsdb)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "bsdb" has 1 instance(s).
Instance "bsdb", status READY, has 1 handler(s) for this service...
Service "factXDB" has 1 instance(s).
Instance "bsdb", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@bsdb trace]$ pwd
/home/app/oracle/diag/tnslsnr/bsdb/listener/trace
[oracle@bsdb trace]$ ls
listener.log listener.log_1025_bak listener.log_bak20181212
[oracle@bsdb trace]$ ll -thr
total 13G
-rw-r----- 1 oracle oinstall 2.3G Dec 12 2018 listener.log_bak20181212
-rw-r----- 1 oracle oinstall 3.5G Oct 25 2019 listener.log_1025_bak
-rw-r----- 1 oracle oinstall 7.3G May 24 18:32 listener.log
[oracle@bsdb trace]$
[oracle@bsdb trace]$ lsnrctl set log_status off
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 24-MAY-2021 18:34:31
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=bsdb)(PORT=1521)))
LISTENER parameter "log_status" set to OFF
The command completed successfully
[oracle@bsdb trace]$
[oracle@bsdb trace]$ mv listener.log listener.log_20210524
[oracle@bsdb trace]$ ll -thr
total 13G
-rw-r----- 1 oracle oinstall 2.3G Dec 12 2018 listener.log_bak20181212
-rw-r----- 1 oracle oinstall 3.5G Oct 25 2019 listener.log_1025_bak
-rw-r----- 1 oracle oinstall 7.3G May 24 18:34 listener.log_20210524
[oracle@bsdb trace]$ echo /dev/null > listener.log
[oracle@bsdb trace]$ lsnrctl set log_status on
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 24-MAY-2021 18:34:55
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=bsdb)(PORT=1521)))
LISTENER parameter "log_status" set to ON
The command completed successfully
[oracle@bsdb trace]$
[oracle@bsdb trace]$ ll -thr
total 13G
-rw-r----- 1 oracle oinstall 2.3G Dec 12 2018 listener.log_bak20181212
-rw-r----- 1 oracle oinstall 3.5G Oct 25 2019 listener.log_1025_bak
-rw-r----- 1 oracle oinstall 7.3G May 24 18:34 listener.log_20210524
-rw-r--r-- 1 oracle oinstall 2.3K May 24 18:34 listener.log
[oracle@bsdb trace]$
[oracle@bsdb trace]$ tail -10f listener.log
24-MAY-2021 18:35:03 * (CONNECT_DATA=(CID=(PROGRAM=)(HOST=__jdbc__)(USER=bsdba))(SERVICE_NAME=bsdb)(CID=(PROGRAM=)(HOST=__jdbc__)(USER=bsdba))) * (ADDRESS=(PROTOCOL=tcp)(HOST=2.10.3.2)(PORT=50670)) * establish * bsdb * 0
24-MAY-2021 18:35:03 * (CONNECT_DATA=(CID=(PROGRAM=)(HOST=__jdbc__)(USER=bsdba))(SERVICE_NAME=bsdb)(CID=(PROGRAM=)(HOST=__jdbc__)(USER=bsdba))) * (ADDRESS=(PROTOCOL=tcp)(HOST=2.10.3.2)(PORT=50672)) * establish * bsdb * 0
24-MAY-2021 18:35:04 * (CONNECT_DATA=(CID=(PROGRAM=)(HOST=__jdbc__)(USER=bsdba))(SERVICE_NAME=bsdb)(CID=(PROGRAM=)(HOST=__jdbc__)(USER=bsdba))) * (ADDRESS=(PROTOCOL=tcp)(HOST=2.10.3.2)(PORT=50674)) * establish * bsdb * 0
24-MAY-2021 18:35:04 * service_update * bsdb * 0