[Home]

Summary:ASTERISK-25305: Dynamic logger channels can be added multiple times
Reporter:Mark Michelson (mmichelson)Labels:
Date Opened:2015-08-05 14:59:31Date Closed:2015-09-25 11:00:19
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Core/Logging
Versions:13.4.0 Frequency of
Occurrence
Constant
Related
Issues:
is related toASTERISK-25566 Double log entries
Environment:Attachments:
Description:The {{logger add channel}} command attempts to determine if the specified log channel exists before adding the new channel. Unfortunately, this does not work properly when relative paths are specified for the logger channel.

If I run {{logger add channel bob debug}} then that will create a logger channel in the configured log directory (by default /var/log/asterisk/). If I run the command a second time, then the CLI command attempts to find if the channel exists already. Unfortunately, the comparison it runs is to check if "/var/log/asterisk/bob" matches "bob". Since this does not match, an identical logger channel is created. You can continue running the command as much as you want. The result can be something like:

{noformat}
*CLI> logger show channels
Channel                             Type     Status    Configuration
-------                             ----     ------    -------------
/var/log/asterisk/bob               File     Enabled    - DEBUG
/var/log/asterisk/bob               File     Enabled    - DEBUG
/var/log/asterisk/bob               File     Enabled    - DEBUG
/var/log/asterisk/bob               File     Enabled    - DEBUG
/var/log/asterisk/bob               File     Enabled    - DEBUG
/var/log/asterisk/bob               File     Enabled    - DEBUG
/var/log/asterisk/bob               File     Enabled    - DEBUG
/var/log/asterisk/bob               File     Enabled    - DEBUG
/var/log/asterisk/bob               File     Enabled    - DEBUG
/var/log/asterisk/bob               File     Enabled    - DEBUG
/var/log/asterisk/bob               File     Enabled    - DEBUG
/var/log/asterisk/bob               File     Enabled    - DEBUG
/var/log/asterisk/bob               File     Enabled    - DEBUG
/var/log/asterisk/bob               File     Enabled    - DEBUG
/var/log/asterisk/bob               File     Enabled    - DEBUG
/var/log/asterisk/bob               File     Enabled    - DEBUG
/var/log/asterisk/bob               File     Enabled    - DEBUG
/var/log/asterisk/bob               File     Enabled    - DEBUG
/var/log/asterisk/alice             File     Enabled    - NOTICE
/var/log/asterisk/bob               File     Enabled    - NOTICE
/var/log/asterisk/bob               File     Enabled    - NOTICE
/var/log/asterisk/full              File     Enabled    - DEBUG NOTICE WARNING ERROR VERBOSE DTMF FAX
/var/log/asterisk/messages          File     Enabled    - NOTICE WARNING ERROR
                                   Console  Enabled    - DEBUG NOTICE WARNING ERROR
{noformat}

And if you check on the contents of the bob file after placing a call, you'll see something like:
{noformat}
[Aug  5 14:26:45] DEBUG[15788] res_pjsip_session.c: Response is 200 OK
[Aug  5 14:26:45] DEBUG[15788] res_pjsip_session.c: Response is 200 OK
[Aug  5 14:26:45] DEBUG[15788] res_pjsip_session.c: Response is 200 OK
[Aug  5 14:26:45] DEBUG[15788] res_pjsip_session.c: Response is 200 OK
[Aug  5 14:26:45] DEBUG[15788] res_pjsip_session.c: Response is 200 OK
[Aug  5 14:26:45] DEBUG[15788] res_pjsip_session.c: Response is 200 OK
[Aug  5 14:26:45] DEBUG[15788] res_pjsip_session.c: Response is 200 OK
[Aug  5 14:26:45] DEBUG[15788] res_pjsip_session.c: Response is 200 OK
[Aug  5 14:26:45] DEBUG[15788] res_pjsip_session.c: Response is 200 OK
[Aug  5 14:26:45] DEBUG[15788] res_pjsip_session.c: Response is 200 OK
[Aug  5 14:26:45] DEBUG[15788] res_pjsip_session.c: Response is 200 OK
[Aug  5 14:26:45] DEBUG[15788] res_pjsip_session.c: Response is 200 OK
[Aug  5 14:26:45] DEBUG[15788] res_pjsip_session.c: Response is 200 OK
[Aug  5 14:26:45] DEBUG[15788] res_pjsip_session.c: Response is 200 OK
[Aug  5 14:26:45] DEBUG[15788] res_pjsip_session.c: Response is 200 OK
[Aug  5 14:26:45] DEBUG[15788] res_pjsip_session.c: Response is 200 OK
[Aug  5 14:26:45] DEBUG[15788] res_pjsip_session.c: Response is 200 OK
[Aug  5 14:26:45] DEBUG[15788] res_pjsip_session.c: Response is 200 OK
{noformat}

Yep, the message is written to the file once for each time that the bob channel shows up in the list of logger channels.

The fix for this is to normalize the CLI input to match what the stored log channel will be, and then perform the comparison.
Comments: