Skip to content

Instantly share code, notes, and snippets.

@frazerh
Created May 3, 2012 16:15
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save frazerh/2586877 to your computer and use it in GitHub Desktop.
Save frazerh/2586877 to your computer and use it in GitHub Desktop.
MACOSX LION HAProxy Logging
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
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
@haroldyong
Copy link

very good. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment