Haproxy log Cutting

Source: Internet
Author: User

(1) Cancel logging in the/var/log/messages directory.

Haproxy logs are also recorded in/var/log/message by default.

# Vi/etc/rsyslog. conf

Local3. */var/log/haproxy. Log

Local0. */var/log/haproxy. Log

*. Info; mail. None; authpriv. None; cron. None; local3.none/var/log/messages


(2) haproxy log Cutting

The haproyx log cutting script is not ready-to-use. It specifically writes a log cutting script to achieve daily log cutting. To add it to the scheduled task, Su root-C must force the root permission to execute it. To retain access logs, you can modify the script implementation.

#! /Bin/bash

# Author: Jun

# Desc:

# Date: 2014-07-07

# Version: V1.0

# Modify:

# Cut haproxy log

MV/var/log/haproxy. log/var/log/haproxy. log. Bak

If [-E/var/log/haproxy. log. Bak]; then

Logrotate-F/etc/logrotate. conf

Chown nobody: Nobody/var/log/haproxy. Log

Chmod + x/var/log/haproxy. Log

Fi

Sleep 1

If [-E/var/log/haproxy. Log]; then

Rm-RF/var/log/haproxy. log. Bak

Fi


(3) haproxy configuration file records

Global

Log 127.0.0.1 local0

Maxconn 65535

Chroot/usr/local/haproxy

UID 99

GID 99

Stats socket/usr/local/haproxy/haproxsocket level admin

Daemon

Nbproc 1

Pidfile/usr/local/haproxy. PID

# Debug

Ults

Log 127.0.0.1 local3

Mode HTTP

Option httplog

Option httplog CLF

Option httpclose

# Option dontlognull

Option forwardfor

Option redispatch

Retries 2

Maxconn 2000

Balance Source

# Balance roundrobin

Stats uri/haproxy-Stats

Stats refresh 10 s

Contimeout 5000

Clitimeout 50000

Srvtimeout 50000

Listen app_cluster 0.0.0.0: 80

Mode HTTP

Option httpchk get/test.html HTTP/1.0 rnhost: 192.168.0.110

Server 192.168.0.111 _ node1 192.168.0.111: 80 weight 3 check inter 2000 rise 2 fall 1

Server 192.168.0.112 _ node2 192.168.0.112: 80 weight 3 check inter 2000 rise 2 fall 1

Server 192.168.0.113 _ node3 192.168.0.113: 80 weight 3 check inter 2000 rise 2 fall 1

Listen stats_auth 0.0.0.0: 91

Mode HTTP

Stats enable

Stats uri/admin

Stats realm "login"

Stats auth admin: 123456

# Stats hide-version

Stats refresh 10 s

Stats admin if true

(4) restart the service

/Etc/init. d/rsyslog restart

/Etc/init. d/haproxy restart

This article is from the "Lonely (Technology Group: 1991706)" blog, please be sure to keep this source http://304076020.blog.51cto.com/7503470/1435227

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.