如何在Mac上启动Syslogd服务器以接受远程日志记录消息?

问题描述:

任何人都知道如何在Mac上启动Syslogd服务器以接受远程日志记录消息吗?

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

我启动了Syslogd,但是似乎它不接受远程消息.

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

如果我执行netstat -an,似乎udp端口514正在监听.但是,如果我使用nmap从笔记本电脑扫描服务器,则看不到udp514.很可能是某个位置的端口被阻塞.我已经检查了ipfw,但它看起来不像定义的任何规则.

If I do a netstat -an it looks like udp port 514 is listening. However, if I scan the server from my laptop using nmap then I don't see udp 514. It's likely the port is being blocked somewhere. I have checked ipfw but it does not look like any rules defined.

我已经看到很多文章说必须指定-r选项.在Mac上也一样吗? 在Mac上该怎么做?

I've seen lots of articles say that have to specify -r option. Is this the same on Mac? How to do that on Mac?

Syslogd应该已经在您的系统上运行;您需要做的是启用其UDP侦听选项.这由/System/Library/LaunchDaemons/com.apple.syslogd.plist末尾附近的部分控制;删除注释标记,使其看起来像这样:

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:

<!--
        Un-comment the following lines to enable the network syslog protocol listener.
-->
                <key>NetworkListener</key>
                <dict>
                        <key>SockServiceName</key>
                        <string>syslog</string>
                        <key>SockType</key>
                        <string>dgram</string>
                </dict>
        </dict>
</dict>
</plist>

然后通过重新引导或运行以下命令重新加载syslogd守护程序:

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

更新:从OS X v10.7开始,Apple将com.apple.syslogd.plist切换为二进制plist格式,该格式不包含相关注释,并且不能作为纯文本进行编辑.使用新格式,PlistBuddy似乎是添加侦听器的最简单方法:

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