Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Haproxy configuration log and custom log

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Log level:

The emerg 0 system is not available

Events in which alert 1 must act immediately

Key events in crit 2

Err 3 error event

Warning 4 warning event

Notice 5 ordinary but important events

Info 6 useful information

Debug 7 debugging Information

Configure logging:

By default, haproxy does not log.

Configure haproxy.cfg to log

Haproxy.cfg: enable haproxy logging

Log 127.0.0.1 local2

/ etc/rsyslog.conf: use rsyslog to receive logs:

Remove the comments from these two lines:

$ModLoad imudp

$UDPServerRun 514

Add this line:

Local2.* / var/log/haproxy.log

Restart rsyslog to see if port 514 of udp is enabled:

# / etc/init.d/rsyslog restart

# netstat-tunpl

Configure haproxy to log in more detail:

The default log is not readable, and we need to display more information, but it cannot be captured by default, so we can only customize what needs to be displayed.

Capture request header Host len 64

Capture request header User-Agent len 128

Capture request header X-Forwarded-For len 100

Capture request header Referer len 200

Capture response header Server len 40

Capture response header Server-ID len 40

Log-format% ci:%cp\% si:%sp\% B\% U\% ST\% r\% b\% f\% bi\% hrl\% hsl\

Just restart haproxy.

Capture request header reference official website: http://cbonte.github.io/haproxy-dconv/1.7/configuration.html#8.8

The custom log format can be found on the official website: http://cbonte.github.io/haproxy-dconv/1.7/configuration.html#8.2.4

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report