{"id":770,"date":"2021-01-08T12:07:09","date_gmt":"2021-01-08T12:07:09","guid":{"rendered":"https:\/\/www.velaninfo.com\/rs\/?post_type=techtips&#038;p=770"},"modified":"2021-01-08T12:07:09","modified_gmt":"2021-01-08T12:07:09","slug":"how-to-configure-haproxy-logging-on-centos","status":"publish","type":"techtips","link":"https:\/\/www.velaninfo.com\/rs\/techtips\/how-to-configure-haproxy-logging-on-centos\/","title":{"rendered":"How to Configure HAProxy Logging on CentOS"},"content":{"rendered":"<p>HAProxy is an <a href=\"https:\/\/velaninfo.com\/mobility-services\"><strong>open source software<\/strong><\/a> that provides a high availability, load balancer and proxy server for TCP and HTTP based applications that spreads requests across multiple server. Most of the HAProxy installation is not configured with store logs.<\/p>\n<p>Steps to install and configure HAProxy with store log is as follows<\/p>\n<p><strong>Installation and Enabling HAProxy<\/strong><\/p>\n<p># dnf install haproxy<\/p>\n<p>To enable and start the service<\/p>\n<p>#systemctl enable haproxy.service<\/p>\n<p>On running the command, the following output is shown<\/p>\n<p><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Created symlink \/etc\/systemd\/system\/multi-user.target.wants\/haproxy.service \u2192 \/usr\/lib\/systemd\/system\/haproxy.service\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/em><\/p>\n<p>To start the service, use the following command \u2013<\/p>\n<p><em>#systemctl start haproxy.service<\/em><\/p>\n<p>To check the status of the service, use the following command \u2013<\/p>\n<p><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #systemctl status haproxy.service<\/em><\/p>\n<p>HAProxy service is running on server now. The next step is to configure the logging process<\/p>\n<p><strong>Configuring HAProxy Logging <\/strong><\/p>\n<p>Open \/etc\/haproxy\/haproxy.cfg in any editor like vim or vi or nano<\/p>\n<p><em>#vi \/etc\/haproxy\/haproxy.cfg<\/em><\/p>\n<p>Comment out the line \u201clog 127.0.0.1 local2\u201d<\/p>\n<p><em>#log 127.0.0.1 local2<\/em><\/p>\n<p><em>chroot \/var\/lib\/haproxy<\/em><\/p>\n<p><em>pidfile \/var\/run\/haproxy.pid<\/em><\/p>\n<p>The next step is to add a line \u201clog\/dev\/log local0\u201dbelow the commented (# ) line<\/p>\n<p>This will create a file inside the directory that has Rsyslog and it will use Rsyslog to collect log entries.<\/p>\n<p>Save the changes made to \/etc\/haproxy\/haproxy.cfg<\/p>\n<p>The next step is to create the dev directory in \/var\/lib\/haproxy<\/p>\n<p><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 # mkdir \/var\/lib\/haproxy\/dev<\/em><\/p>\n<p><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 # systemctl restart haproxy.service<\/em><\/p>\n<p><strong>Configuration of Rsyslog to collect HAProxy Logs<\/strong><\/p>\n<p>Create a new file \/etc\/rsyslog.d\/xyz-haproxy.conf using an editor like vi, vim or nano<\/p>\n<p><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 # vi \/etc\/rsyslog.d\/xyz-haproxy.conf<\/em><\/p>\n<p>Add the following lines to the file and save the file.<\/p>\n<p><em># AddUnixListenSocket \/var\/lib\/haproxy\/dev\/log<\/em><\/p>\n<p><em># Send HAProxy messages to a dedicated logfile<\/em><\/p>\n<p><em>:programname, startswith, &#8220;haproxy&#8221; {<\/em><\/p>\n<p><em>\/var\/log\/haproxy.log<\/em><\/p>\n<p><em>stop<\/em><\/p>\n<p><em>}<\/em><\/p>\n<p>Haproxy will log the details in rsyslog.<\/p>\n<p>At <strong>Velan<\/strong>, our server support engineers can help you configure HAProxy and setup logging to a file on your server. We troubleshoot problems like these for our clients every day.\u00a0If you are interested in our service, please fill the <a href=\"https:\/\/velaninfo.com\/contact\"><strong>Quick connect<\/strong><\/a> form to get in touch with us<\/p>\n","protected":false},"excerpt":{"rendered":"<p>HAProxy is an open source software that provides a high availability, load balancer and proxy server for TCP and HTTP based applications that spreads requests across multiple server. Most of the HAProxy installation is not configured with store logs. Steps to install and configure HAProxy with store log is as follows Installation and Enabling HAProxy&#8230;<a class=\"continue-reading text-uppercase\" href=\"https:\/\/www.velaninfo.com\/rs\/techtips\/how-to-configure-haproxy-logging-on-centos\/\"> Continue Reading <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.velaninfo.com\/rs\/wp-content\/themes\/velaninfo\/images\/reading_arw.png\" alt=\"Continue Reading\" width=\"16\" height=\"12\"\/><\/a><\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"tags":[],"class_list":["post-770","techtips","type-techtips","status-publish","hentry","Categories_tech_tip-linux","Categories_tech_tip-server"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v19.5 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Configure HAProxy Logging on CentOS | Velan<\/title>\n<meta name=\"description\" content=\"Steps to install and configure HAProxy with store log as file\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.velaninfo.com\/rs\/techtips\/how-to-configure-haproxy-logging-on-centos\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Configure HAProxy Logging on CentOS\" \/>\n<meta property=\"og:description\" content=\"Steps to install and configure HAProxy with store log as file\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.velaninfo.com\/rs\/techtips\/how-to-configure-haproxy-logging-on-centos\/\" \/>\n<meta property=\"og:site_name\" content=\"Velan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.velaninfo.com\\\/rs\\\/techtips\\\/how-to-configure-haproxy-logging-on-centos\\\/\",\"url\":\"https:\\\/\\\/www.velaninfo.com\\\/rs\\\/techtips\\\/how-to-configure-haproxy-logging-on-centos\\\/\",\"name\":\"How to Configure HAProxy Logging on CentOS | Velan\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.velaninfo.com\\\/rs\\\/#website\"},\"datePublished\":\"2021-01-08T12:07:09+00:00\",\"description\":\"Steps to install and configure HAProxy with store log as file\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.velaninfo.com\\\/rs\\\/techtips\\\/how-to-configure-haproxy-logging-on-centos\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.velaninfo.com\\\/rs\\\/techtips\\\/how-to-configure-haproxy-logging-on-centos\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.velaninfo.com\\\/rs\\\/techtips\\\/how-to-configure-haproxy-logging-on-centos\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.velaninfo.com\\\/rs\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tech Tips\",\"item\":\"https:\\\/\\\/www.velaninfo.com\\\/rs\\\/techtips\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to Configure HAProxy Logging on CentOS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.velaninfo.com\\\/rs\\\/#website\",\"url\":\"https:\\\/\\\/www.velaninfo.com\\\/rs\\\/\",\"name\":\"Velan\",\"description\":\"Velaninfo Services India Pvt Ltd\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.velaninfo.com\\\/rs\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Configure HAProxy Logging on CentOS | Velan","description":"Steps to install and configure HAProxy with store log as file","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.velaninfo.com\/rs\/techtips\/how-to-configure-haproxy-logging-on-centos\/","og_locale":"en_US","og_type":"article","og_title":"How to Configure HAProxy Logging on CentOS","og_description":"Steps to install and configure HAProxy with store log as file","og_url":"https:\/\/www.velaninfo.com\/rs\/techtips\/how-to-configure-haproxy-logging-on-centos\/","og_site_name":"Velan","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.velaninfo.com\/rs\/techtips\/how-to-configure-haproxy-logging-on-centos\/","url":"https:\/\/www.velaninfo.com\/rs\/techtips\/how-to-configure-haproxy-logging-on-centos\/","name":"How to Configure HAProxy Logging on CentOS | Velan","isPartOf":{"@id":"https:\/\/www.velaninfo.com\/rs\/#website"},"datePublished":"2021-01-08T12:07:09+00:00","description":"Steps to install and configure HAProxy with store log as file","breadcrumb":{"@id":"https:\/\/www.velaninfo.com\/rs\/techtips\/how-to-configure-haproxy-logging-on-centos\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.velaninfo.com\/rs\/techtips\/how-to-configure-haproxy-logging-on-centos\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.velaninfo.com\/rs\/techtips\/how-to-configure-haproxy-logging-on-centos\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.velaninfo.com\/rs\/"},{"@type":"ListItem","position":2,"name":"Tech Tips","item":"https:\/\/www.velaninfo.com\/rs\/techtips\/"},{"@type":"ListItem","position":3,"name":"How to Configure HAProxy Logging on CentOS"}]},{"@type":"WebSite","@id":"https:\/\/www.velaninfo.com\/rs\/#website","url":"https:\/\/www.velaninfo.com\/rs\/","name":"Velan","description":"Velaninfo Services India Pvt Ltd","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.velaninfo.com\/rs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/techtips\/770","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/techtips"}],"about":[{"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/types\/techtips"}],"author":[{"embeddable":true,"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/comments?post=770"}],"version-history":[{"count":1,"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/techtips\/770\/revisions"}],"predecessor-version":[{"id":771,"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/techtips\/770\/revisions\/771"}],"wp:attachment":[{"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/media?parent=770"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/tags?post=770"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}