有沒有人知道haproxy在mac osx上寫日誌的地方? 我想使用capture cookie _secure len 32
登錄到我的rails後端的安全cookie。haproxy登錄mac osx
我檢查了Console.app,但日誌沒有顯示在那裏。
有沒有人知道haproxy在mac osx上寫日誌的地方? 我想使用capture cookie _secure len 32
登錄到我的rails後端的安全cookie。haproxy登錄mac osx
我檢查了Console.app,但日誌沒有顯示在那裏。
HAProxy記錄到系統日誌,所以你是正確的,檢查Console.app來查看輸出。
問題是,在OSX上,您首先需要設置syslog以包含它的網絡偵聽器。
這裏是爲我工作[source]說明:
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
在haproxy上使用dtruss來查看它們被寫入的位置。在觀看時應該會看到文件I/O系統調用。
更好的是,它是開源的。只要看看代碼。
看到,因爲我無法評論(噓,聲望)我想補充以下內容alanning:
萬一您正在運行OS X 10.11+(El Capitan或更新版本)並且無法複製plist文件(即使使用sudo),您可能會遇到Apple新的系統完整性保護。
要禁用SIP:
csrutil disable
強烈建議您按照相同的步驟重新啓用SIP,但
How to disable rootless mode on Stack Overflow
System Integrity Protection on Apple.com
:在步驟3中參考使用csrutil enable