mac osx 上的 haproxy 日志记录

Pra*_*oya 5 macos logging haproxy

有谁知道 haproxy 在 mac osx 上将日志写入哪里?我想使用 记录进入我的 Rails 后端的安全 Cookie capture cookie _secure len 32

我检查了 Console.app,但日志没有显示在那里。

ala*_*ing 4

HAProxy 记录到 syslog,因此您检查 Console.app 以查看输出是正确的。

问题是,在 OSX 上,您首先需要设置 syslog 以包含其网络侦听器。

以下是对我有用的说明[来源]

 HA Proxy Logging on Lion
 -------------------------

 # To enable haproxy logging we need to change syslogd
 # startup procedure to include its network listener.

 # Backup syslogd start up file
 sudo cp /System/Library/LaunchDaemons/com.apple.syslogd.plist   /System/Library/LaunchDaemons/com.apple.syslogd.plist.bakup


 # Convert binary file to xml to be human readable / editable
 sudo plutil -convert xml1 /System/Library/LaunchDaemons/com.apple.syslogd.plist

 # Edit /System/Library/LaunchDaemons/com.apple.syslogd.plist 
 # and add the following snippet under the sockets  node

 <key>NetworkListener</key>
 <dict>
   <key>SockServiceName</key>
   <string>syslog</string>
   <key>SockType</key>
   <string>dgram</string>
 </dict>

 # Should read like this now
 <key>Sockets</key>
 <dict>
    <key>AppleSystemLogger</key>
    <dict>
        <key>SockPathMode</key>
        <integer>438</integer>
        <key>SockPathName</key>
        <string>/var/run/asl_input</string>
    </dict>
    <key>BSDSystemLogger</key>
    <dict>
        <key>SockPathMode</key>
        <integer>438</integer>
        <key>SockPathName</key>
        <string>/var/run/syslog</string>
        <key>SockType</key>
        <string>dgram</string>
    </dict>
    <key>NetworkListener</key>
    <dict>
        <key>SockServiceName</key>
        <string>syslog</string>
        <key>SockType</key>
        <string>dgram</string>
    </dict>
 </dict>

 # Save the file

 # Convert back to binary file
 sudo plutil -convert binary1 /System/Library/LaunchDaemons/com.apple.syslogd.plist

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

 # I added the following entry to /etc/syslog.conf
 local2.*                       /var/log/haproxy.log

 # Include logging options in haproxy.cfg
 global
    log 127.0.0.1   local2 debug

 defaults
    mode http
    option httplog
    log global


 # Restart HAproxy
Run Code Online (Sandbox Code Playgroud)