[asterisk-users] Problems sending log to rsyslog

Mauricio Tavares raubvogel at gmail.com
Fri Sep 27 07:46:51 CDT 2013


On Thu, Sep 26, 2013 at 11:16 AM, Gareth Blades
<mailinglist+asterisk at dns99.co.uk> wrote:
> On 26/09/13 15:25, Mauricio Tavares wrote:
>>
>>        So I have asterisk 1.8.23 and want to send my logs to rsyslog. I
>> tell asterisk to use syslog in addition to messages:
>>
>> root at voip:~# tail -10 /etc/asterisk/logger.conf
>> ;debug =>  debug
>> console =>  notice,warning,error
>> ;console =>  notice,warning,error,debug
>> messages =>  notice,warning,error
>> ;full =>  notice,warning,error,debug,verbose,dtmf,fax
>>
>> ;syslog keyword : This special keyword logs to syslog facility
>> ;
>> syslog.local0 =>  notice,warning,error
>> ;
>> root at voip:~#
>>
>> After reloading (asterisk -rx 'logger reload') the logger, it seems
>> that Asterisk is happy:
>>
>> root at voip:~# asterisk -rx 'logger show channels'
>> Channel                             Type     Status    Configuration
>> -------                             ----     ------    -------------
>> syslog.local0                       Syslog   Enabled    - NOTICE WARNING
>> ERROR
>> /var/log/asterisk/messages          File     Enabled    - NOTICE WARNING
>> ERROR
>>                                      Console  Enabled    - NOTICE WARNING
>> ERROR
>> root at voip:~#
>>
>> So I set rsyslog:
>>
>> root at voip:~# fgrep asterisk /etc/rsyslog.d/50-default.conf
>> local0.*                       /var/log/asterisk/messages.log
>> root at voip:~#
>>
>> and restart it. And then check the asterisk log directory:
>>
>> root at voip:~# ls -lh /var/log/asterisk/
>> total 3.7M
>> drwxr-xr-x 2 asterisk asterisk 4.0K Jul 22 20:57 cdr-csv
>> drwxr-xr-x 2 asterisk asterisk 4.0K Jun 28 14:16 cdr-custom
>> -rw-rw---- 1 asterisk asterisk 252K Sep 26 09:37 messages
>> -rw-rw---- 1 asterisk asterisk 248K Sep 22 05:14 messages.1
>> -rw-r----- 1 syslog   adm         0 Sep 26 06:47 messages.log
>> -rw-rw---- 1 asterisk asterisk  118 Sep 26 10:07 queue_log
>> root at voip:~#
>>
>> It does not seem like much is being written to messages.log compared
>> to messages. Anything I missed?
>>
> Have you checked the /var/log/asterisk directory permissions?
>
> I dont know how rsyslog is setup on your system but its possible it gets
> started as root, sees the destination file doesnt exist so creates it and
> sets the file permissions, and then drops down to running as the syslog
> user. At this point it doesnt have write permission to the /var/log/asterisk
> directory so cannot append to the file.
>
      And you were absolutely right:

root at voip:~# sudo -u syslog touch /var/log/asterisk/my_nose
touch: cannot touch `/var/log/asterisk/my_nose': Permission denied
root at voip:~# ls -lhd /var/log/asterisk
drwxr-xr-x 4 asterisk asterisk 4.0K Sep 26 10:10 /var/log/asterisk
root at voip:~# getent group asterisk
asterisk:x:114:www-data
root at voip:~#

So, I decided to be lazy and add syslog to the asterisk group:

root at voip:~# id syslog
uid=101(syslog) gid=103(syslog) groups=114(asterisk),103(syslog)
root at voip:~# chmod g+w /var/log/asterisk
root at voip:~# sudo -u syslog touch /var/log/asterisk/my_nose
root at voip:~#

Thanks!
>
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
> New to Asterisk? Join us for a live introductory webinar every Thurs:
>               http://www.asterisk.org/hello
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/mailman/listinfo/asterisk-users



More information about the asterisk-users mailing list