–========================
—   Oracle Listener log configuration and management
–========================  
    Oracle The listener is a server-side program , Used to listen for all requests from clients , And provide database services for it . Therefore, the management and maintenance of the monitor is very important .  

In this paper, we mainly describe the relationship between Oracle Configuration and management of listener log files . For a description of the listener, please refer to

       To configure ORACLE The client connects to the database  

     Configure dynamic service registration for non default ports     

One 、 Listener logging features

1.  The listener log is a plain text file , Usually located in $ORACLE_HOME/network/log Under the table of contents , And sqlnet.log Log files are in the same path               

2.  The default file name is listener.log. For non default listeners , The generated log file is usually listenername.log                          

3.  This file is automatically created by the listener by default , When the log file is missing or does not exist , Will automatically recreate a file with the same name , And alert_<SID>.log File similar    

4.  The size of the file will continue to grow automatically , When the size is too large or not easy to read , Consider backing it up                                               

5.  Oracle The listener is not allowed to delete log files at runtime , Rename operation                                                             

6.  You can set the log status to ON or OFF To enable or disable logging        

Two 、 Set the log file directory and path

       1.  Two ways to set the log file directory         

[sql]             view plain       copy         print      ?    

  1. lsnrctl SET LOG_DIRECTORY directory  
  2.           
  3. LSNRCTL> SET LOG_DIRECTORY /usr/oracle/admin/log  

       2.   Two ways to set up log files         

[sql]             view plain       copy         print      ?    

  1. lsnrctl SET LOG_FILE file_name  
  2.          
  3. LSNRCTL> SET LOG_FILE file_name  

       3.   Set the status of the log         

[sql]             view plain       copy         print      ?    

  1. lsnrctl SET LOG_STATUS {on | off}  
  2.   
  3. LSNRCTL> SET LOG_STATUS {on | off}  

       4.   Demo settings  
        a.   Switch to the log directory to view the log file             

[sql]             view plain       copy         print      ?    

  1. [oracle@test ~]$ cd $ORACLE_HOME/network/log      
  2. [oracle@test log]$ ls -hltr  
  3. total 348K  
  4. -rw-r–r–  1 oracle oinstall 305K Apr  6 05:30 listener.log  
  5. -rw-r–r–  1 oracle oinstall  26K Jun 27 01:52 listener_demo92.log  

       b.   View the status of the current listener             

[sql]             view plain       copy         print      ?    

  1. [oracle@test log]$ lsnrctl status listener_demo92  
  2.              
  3. LSNRCTL for Linux: Version 9.2.0.8.0 – Production on 27-JUN-2011 01:54:31  
  4.              
  5. Copyright (c) 1991, 2006, Oracle Corporation.  All rights reserved.  
  6.              
  7. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test)(PORT=1521)))  
  8. STATUS of the LISTENER  
  9. ————————  
  10. Alias                     listener_demo92  
  11. Version                   TNSLSNR for Linux: Version 9.2.0.8.0 – Production  
  12. Start Date                27-JUN-2011 01:52:18  
  13. Uptime                    0 days 0 hr. 2 min. 13 sec  
  14. Trace Level               off  
  15. Security                  ON  
  16. SNMP                      OFF  
  17. Listener Parameter File   /oracle/92/network/admin/listener.ora  
  18. Listener Log File         /oracle/92/network/log/listener_demo92.log  
  19. Listening Endpoints Summary…  
  20. (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test)(PORT=1521)))  
  21. (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))  
  22. Services Summary…  
  23. Service “demo92” has 1 instance(s).  
  24.              Instance “demo92”, status READY, has 1 handler(s) for this service…  
  25.            The command completed successfully          
  26.          

        c.   Set listener directory and log file

[sql]             view plain       copy         print      ?    

  1. LSNRCTL> set current_listener listener_demo92                                    
  2. Current Listener is listener_demo92                                              
  3. LSNRCTL> set password                                                            
  4. Password:                                                                        
  5. The command completed successfully                                               
  6. LSNRCTL> set log_directory /home/oracle/log                                      
  7. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test)(PORT=1521)))       
  8. listener_demo92 parameter “log_directory” set to /home/oracle/log                
  9. The command completed successfully                                               
  10. LSNRCTL> set log_file listener_test.log                                          
  11. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test)(PORT=1521)))       
  12. listener_demo92 parameter “log_file” set to listener_test.log                    
  13. The command completed successfully                                               
  14. LSNRCTL> set log_status on                                                       
  15. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test)(PORT=1521)))       
  16. listener_demo92 parameter “log_status” set to ON                                 
  17. The command completed successfully                                               
  18. LSNRCTL> save_config                                                             
  19. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test)(PORT=1521)))       
  20. Saved listener_demo92 configuration parameters.                                  
  21. Listener Parameter File   /oracle/92/network/admin/listener.ora                  
  22. Old Parameter File   /oracle/92/network/admin/listener.bak                       
  23. The command completed successfully                                               
  24. LSNRCTL> exit                                                                    

        d.   View the log file generated under the new path    

[sql]             view plain       copy         print      ?    

  1. [oracle@test admin]$ cd /home/oracle/log                                                                
  2. [oracle@test log]$ ls -hltr                                                                             
  3. total 16K                                                                                               
  4. -rw-r–r–  1 oracle oinstall  41 Jun 27 02:11 listener_demo92.log  –> After setting the directory                
  5. -rw-r–r–  1 oracle oinstall 113 Jun 27 02:12 listener_test.log    –> Set the new log file after the log file name    
  6.                                                                                                         
  7. [oracle@test log]$ ls -hltr    –> Check every other time , The original log file no longer grows , Log with the set log file name     
  8. total 16K                                                                                               
  9. -rw-r–r–  1 oracle oinstall   41 Jun 27 02:11 listener_demo92.log                                     
  10. -rw-r–r–  1 oracle oinstall 1.3K Jun 27 02:17 listener_test.log                                       

        e.   see listener.ora Changes in configuration files  

[sql]             view plain       copy         print      ?    

  1. [oracle@test admin]$ more listener.ora               
  2. #—-ADDED BY TNSLSNR 27-JUN-2011 02:12:37—        
  3. LOG_DIRECTORY_listener_demo92 = /home/oracle/log     
  4. LOG_FILE_listener_demo92 = listener_test.log         
  5. LOGGING_listener_demo92 = ON                         
  6. #——————————————–        

3、 … and 、 Backup and rename of log files

     Usually , You need to stop the listener to back up the log file , Next, rename the log file without stopping listening to realize backup  
        1. Windows Platform handling              

[sql]             view plain       copy         print      ?    

  1. C:\>cd \oracle\ora92\network\log     –> Switch to the directory where the listener log file is located                                            
  2. C:\oracle\ora92\network\log> lsnrctl set log_status off –> Pause or log files offline                               
  3. C:\oracle\ora92\network\log> rename listener.log listener.old –> Rename log file , Usually with dates                   
  4. C:\oracle\ora92\network\log> lsnrctl set log_status on –> Online listener log file , A new log file will be created automatically    

        2. Unix/Linux Platform handling             

[sql]             view plain       copy         print      ?    

  1. $ lsnrctl set log_status off                                                                               
  2. $ mv listener.log listener.old –> Another way ,cp listener.log /log/bak/.  then  cp /dev/null >listener.log   
  3. $ lsnrctl set log_status on                                                                                    

        3. demonstration Linux Rename log files under the platform                              

[sql]             view plain       copy         print      ?    

  1. [oracle@test ~]$ cd /home/oracle/log                                                      
  2. [oracle@test log]$ lsnrctl set log_status off  –> If there is a password , You should use LSNRCTL Interface    
  3.                                                                                           
  4. LSNRCTL for Linux: Version 9.2.0.8.0 – Production on 27-JUN-2011 02:41:09                 
  5.                                                                                           
  6. Copyright (c) 1991, 2006, Oracle Corporation.  All rights reserved.                       
  7.                                                                                           
  8. Connecting to (ADDRESS=(PROTOCOL=tcp)(PORT=1521))                                         
  9. LISTENER parameter “log_status” set to OFF                                                
  10. The command completed successfully                                                        
  11. [oracle@test log]$ mv listener_test.log listener_test.old                                 
  12. [oracle@test log]$ lsnrctl set log_status on                                              
  13.                                                                                           
  14. LSNRCTL for Linux: Version 9.2.0.8.0 – Production on 27-JUN-2011 02:41:31                 
  15.                                                                                           
  16. Copyright (c) 1991, 2006, Oracle Corporation.  All rights reserved.                       
  17.                                                                                           
  18. Connecting to (ADDRESS=(PROTOCOL=tcp)(PORT=1521))                                         
  19. LISTENER parameter “log_status” set to ON                                                 
  20. The command completed successfully