How to start Syslogd server on Mac to accept remote logging messages?

前端 未结 2 1925
灰色年华
灰色年华 2021-01-30 04:31

Anyone knows how to start Syslogd server on Mac to accept remote logging messages?

I started Syslogd, but seems it doesn\'t accept remote messages.

If I do a net

2条回答
  •  渐次进展
    2021-01-30 05:14

    Syslogd should already be running on your system; what you need to do is enable its UDP listening option. This is controlled by a section near the end of /System/Library/LaunchDaemons/com.apple.syslogd.plist; remove the comment markers so that it looks like this:

    
                    NetworkListener
                    
                            SockServiceName
                            syslog
                            SockType
                            dgram
                    
            
    
    
    

    And then reload the syslogd daemon either by rebooting, or by running:

    sudo launchctl unload /System/Library/LaunchDaemons/com.apple.syslogd.plist
    sudo launchctl load /System/Library/LaunchDaemons/com.apple.syslogd.plist
    

    UPDATE: Starting in OS X v10.7, Apple switched com.apple.syslogd.plist to a binary plist format, which doesn't include the relevant comment, and isn't editable as plain text. With the new format, PlistBuddy seems to be the easiest way to add the listener:

    cd /System/Library/LaunchDaemons
    sudo /usr/libexec/PlistBuddy -c "add :Sockets:NetworkListener dict" com.apple.syslogd.plist
    sudo /usr/libexec/PlistBuddy -c "add :Sockets:NetworkListener:SockServiceName string syslog" com.apple.syslogd.plist
    sudo /usr/libexec/PlistBuddy -c "add :Sockets:NetworkListener:SockType string dgram" com.apple.syslogd.plist
    sudo launchctl unload com.apple.syslogd.plist
    sudo launchctl load com.apple.syslogd.plist
    

提交回复
热议问题