{"id":577,"date":"2012-11-13T15:43:00","date_gmt":"2012-11-13T20:43:00","guid":{"rendered":"https:\/\/infotechguy.net\/?p=577"},"modified":"2022-08-26T10:01:56","modified_gmt":"2022-08-26T14:01:56","slug":"apache-logs-stop-loggin-certain-uris","status":"publish","type":"post","link":"https:\/\/infotechguy.net\/?p=577","title":{"rendered":"Linux &#8212; Apache Logs -Stop Logging Certain URIs"},"content":{"rendered":"<p>I recently posted an article talking about<a title=\"HTTP Load Balancing with HAProxy 1.4\" href=\"https:\/\/infotechguy.net\/load-balancing-with-haproxy-1-4\/\" target=\"_blank\" rel=\"noopener noreferrer\"> HAProxy as a load balancer<\/a>. In the article I spoke about using a HTML health check file to maintain status of each servers Apache instance. The problem is this will flood your Apache server access logs every time this health check occurs, which I believe is every 2 seconds.<\/p>\n<p>So you end up with a log file like this:<br \/>\n<a href=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/healthcheck-apachelogs.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3557\" src=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/healthcheck-apachelogs-300x186.png\" alt=\"\" width=\"600\" height=\"372\" srcset=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/healthcheck-apachelogs-300x186.png 300w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/healthcheck-apachelogs-768x476.png 768w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/healthcheck-apachelogs.png 1024w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>To correct this issue we need to modify the <strong>apache2.conf<\/strong> file on each server, and explicitly tell Apache <strong>NOT <\/strong>to log this URI to the access logs. So, from the <a title=\"HTTP Load Balancing with HAProxy 1.4\" href=\"https:\/\/infotechguy.net\/load-balancing-with-haproxy-1-4\/\" target=\"_blank\" rel=\"noopener noreferrer\">previous article<\/a> the culprit URI is \/healthcheck.html. Open your Apache configuration file.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo vi \/etc\/apache2\/apache2.conf<\/pre>\n<p>Now add this above the CustomLog section:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#logs \nSetEnvIf Request_URI \"^\/healthcheck.html$\" dontlog \nCustomLog \/www\/logs\/mysite_access_logs combined env=!dontlog \nErrorLog \/www\/logs\/mysite_error_logs<\/pre>\n<p><strong>NOTICE: <\/strong>Make sure you have the &#8221; escape character for any special characters.<\/p>\n<p>That&#8217;s it! No more spamming of all the health checks to our Apache logs!!<\/p>\n<p><strong>Sources:<\/strong><\/p>\n<ul>\n<li>h<a title=\"http:\/\/httpd.apache.org\/docs\/1.3\/logs.html#conditional\" href=\"http:\/\/httpd.apache.org\/docs\/1.3\/logs.html#conditional\" target=\"_blank\" rel=\"noopener noreferrer\">ttp:\/\/httpd.apache.org\/docs\/1.3\/logs.html#conditional<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>I recently posted an article talking about HAProxy as a load balancer. In the article I spoke about using a HTML health check file to maintain status of each servers Apache instance. The problem is&#46;&#46;&#46;<\/p>\n","protected":false},"author":2,"featured_media":4240,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[86],"class_list":["post-577","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-linux"],"_links":{"self":[{"href":"https:\/\/infotechguy.net\/index.php?rest_route=\/wp\/v2\/posts\/577","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/infotechguy.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/infotechguy.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/infotechguy.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/infotechguy.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=577"}],"version-history":[{"count":1,"href":"https:\/\/infotechguy.net\/index.php?rest_route=\/wp\/v2\/posts\/577\/revisions"}],"predecessor-version":[{"id":4195,"href":"https:\/\/infotechguy.net\/index.php?rest_route=\/wp\/v2\/posts\/577\/revisions\/4195"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/infotechguy.net\/index.php?rest_route=\/wp\/v2\/media\/4240"}],"wp:attachment":[{"href":"https:\/\/infotechguy.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=577"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/infotechguy.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=577"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/infotechguy.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=577"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}