Il peut être parfois utile de ne pas logger certains scripts dans les access log d'Apache, histoire de ne pas faire gonfler ces derniers trop vite, ou tout simplement parce que ces logs ne nous sont d'aucune utilité.
Je prends par exemple le cas d'un script ajax qui va appeler régulièrement une page (dans le cadre d'un système de notifications, de shoutbox, etc.). S'il y a beaucoup de monde connecté sur le site en même temps, même s'ils sont inactifs, les access logs vont se remplir.
L'idée est donc de dire à Apache de ne pas logger les appels à tel ou tel script (ou à l'inverse de le faire uniquement pour ceux-ci).
Pour ce faire, nous allons utiliser la directive SetEnvIf du module mod_setenvif d'Apache, ansi que la directive CustomLog.
Son utilisation est relativement simple. Il vous suffit d'éditer votre fichier vhost ou de configuration, et de placer la directive comme suit, avant toute déclaration d'un CustomLog :
SetEnvIf Request_URI "my_page.php$" donotlog
Cette ligne permet de définir une variable d'environnement en fonction de la requête.
Dans notre cas, on dit à Apache de créer la variable "donotlog" dans le cas où l'URL appelée est "my_page.php".
C'est cette variable qui va nous permettre de logger ou non l'appel.
Et pour ça, il suffit d'ajouter un 3 ème argument à la directive CustomLog : une variable d'environnement à tester.
SetEnvIf Request_URI "my_page.php$" donotlog CustomLog /dev/null env=donotlog // on jette à la poubelle tous les logs d'appels CustomLog /var/log/apache2/access_atelier_dev.log combined env=!donotlog // on garde tous les appels où "donotlog" n'est pas défini
Évidement, vous n'êtes pas limité à une seule condition, vous pouvez mettre plusieurs SetEnvIf à la suite et vous pouvez aussi en faire l'usage inverse (= ne logger que les appels à certaines pages).
P-S. : n'oubliez pas de redémarrer Apache pour que les modifications prennent effet !
Commentaires :
# google, le lundi 25 janvier 2021 à 03:10:20 # apartments on lease in magnolias, le vendredi 23 avril 2021 à 02:16:18learnd
cheap
Pour ne pas être amer parce que je reçois malade de cette
awesome job
I'm overjoyed to have discovered your article and look forward to spending several more enjoyable hours browsing it. Once again, thank you for all of the details.
It is vital to obtain feedback on the server's activity and performance, as well as any problems that may arise, in order to efficiently administer a web server. The logging features of the Apache HTTP Server are extensive and configurable. This guide explains how to configure its logging capabilities as well as how to decipher the contents of the logs.
Anyone who visits TikoFoundation will not be disappointed. This is a great website for those who value their time. All you need to do is visit the main page.
Good https://www.google.com work.
I should discover it earlier
Great post
Great post, thank you for this informative content!
this is good information. Very informative
very well said
Great! Thanks for reminding us
focused
great
amazing
such a wonderful pots
thanks
great post
Very interesting information! Perfect just what I was searching for
great post.
nice post.
nice post.
Thank you for sharing. This is amazing!
The matter and content are amazing. Thank you for sharing. All the best!
What a wonderful post.
This is amazing. Thank you!
This is awesome.
The matter and content are amazing. Thank you for sharing. All the best from our <a href="https://seniormarketadvisors.com/">fmo insurance companies</a>
step into the realm of Solos Construction - the epitome of expertise in the realm of stucco and scaffolding nestled amidst the dynamic expanse of Southern California
For all your home improvement and landscape needs in Dartford, Kent, and the surrounding areas, Dartford Construction & Landscaping
Discover the perfect venue solution with Marquee Hire HST. Explore our range of high-quality marquees for hire from weddings to corporate events. Your ideal event space is waiting for you. Contact us today 01424237969 and let's make your party less hassle!
At Orca Marketing, we offer comprehensive digital solutions tailored to elevate your online presence
Transforming spaces with Okie Concrete. Explore our premium concrete services for residential and commercial projects. From driveways to foundations, trust us for durable, expert craftsmanship
Expert pet waste removal in OKC! WeScoopThePoopOKC.com offers hassle-free solutions for cleaner outdoor spaces. Tailored services, client-focused, and pet-friendly expertise. Schedule today! Contact us and request a quote here: https://wescoopthepoopokc.com/
As the UK?s FIRST and ONLY Security Industry Membership based Insurance Company, we are committed to protecting the health, wealth and confidence of licensed security staff across the UK
I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details.