Retour en haut

Ne pas logger certains scripts dans l'access log d'Apache

posté le vendredi 1er mars 2013 à 14:46:07 par delphiki :: Web

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

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.

 
# apartments on lease in magnolias, le vendredi 23 avril 2021 à 02:16:18

learnd

 
# csgo prime accounts, le vendredi 23 avril 2021 à 02:16:56

cheap

 
# www.housecleaningmedfordoregon.com, le vendredi 7 mai 2021 à 11:39:50

Pour ne pas être amer parce que je reçois malade de cette

 
# https://graberfence.com/solar-electric-fences/, le vendredi 7 mai 2021 à 18:02:54

awesome job

 
# https://genius.com/yewzebra0, le mercredi 13 octobre 2021 à 17:46:33

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.

 
# free paint by numbers for pc, le mercredi 13 octobre 2021 à 17:52:29

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.

 
# TikoFoundation, le jeudi 28 octobre 2021 à 07:28:05

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.

 
# Best, le mercredi 3 novembre 2021 à 08:42:10

Good https://www.google.com work.

 
# toiture, le mardi 3 mai 2022 à 21:26:03

I should discover it earlier

 
# Alex, le dimanche 31 juillet 2022 à 07:58:46

Great post

 
# Our site, le dimanche 31 juillet 2022 à 09:42:48

Great post, thank you for this informative content!

 
# Bristol decking, le mardi 4 octobre 2022 à 13:02:35

this is good information. Very informative

 
# Security systems Gloucester, le mardi 4 octobre 2022 à 13:33:56

very well said

 
# help with an electrical accident, le mardi 4 octobre 2022 à 13:54:49

Great! Thanks for reminding us

 
# https://www.carpentercheltenhamspa.co.uk/windows, le mardi 4 octobre 2022 à 13:59:55

focused

 
# win million game, le jeudi 15 juin 2023 à 20:14:21

great

 
# gta game, le jeudi 15 juin 2023 à 20:14:57

amazing

 
# subwat surfers, le jeudi 15 juin 2023 à 20:15:46

such a wonderful pots

 
# clash games, le jeudi 15 juin 2023 à 20:16:25

thanks

 
# padel game, le mardi 19 septembre 2023 à 02:35:18

great post

 
# roofing companies parrish, le jeudi 5 octobre 2023 à 10:22:15

Very interesting information! Perfect just what I was searching for

 
# saudi gold price today, le samedi 14 octobre 2023 à 04:52:15

great post.

 
# uae gold price today, le samedi 14 octobre 2023 à 04:52:36

nice post.

 
# hair vitamins, le samedi 14 octobre 2023 à 04:52:56

nice post.

 
# financial copywriter, le samedi 21 octobre 2023 à 08:55:46

Thank you for sharing. This is amazing!

 
# life insurance colorado, le dimanche 29 octobre 2023 à 05:08:49

The matter and content are amazing. Thank you for sharing. All the best!

 
# buy and sell agreement life insurance, le mercredi 1er novembre 2023 à 08:56:44

What a wonderful post.

 
# medicare sales agent job description, le mardi 20 février 2024 à 15:23:23

This is amazing. Thank you!

 
# medicare field marketing organization, le lundi 26 février 2024 à 21:50:05

This is awesome.

 
# Medicare FMO Companies, le vendredi 8 mars 2024 à 13:23:57

The matter and content are amazing. Thank you for sharing. All the best from our <a href="https://seniormarketadvisors.com/">fmo insurance companies</a>

 
# san diego stucco repair, le jeudi 21 mars 2024 à 13:42:48

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

 
# Dartford Construction, le jeudi 21 mars 2024 à 14:42:57

For all your home improvement and landscape needs in Dartford, Kent, and the surrounding areas, Dartford Construction & Landscaping

 
# Marquee Hire, le samedi 23 mars 2024 à 03:54:41

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!

 
# https://www.orcamkg.com/, le samedi 23 mars 2024 à 11:39:17

At Orca Marketing, we offer comprehensive digital solutions tailored to elevate your online presence

 
# Okie Concrete Contractor, le lundi 25 mars 2024 à 12:43:58

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

 
# Oklahoma Pet waste removal, le lundi 25 mars 2024 à 13:23:23

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/

 
# Security Staff Insurance, le mercredi 27 mars 2024 à 13:54:25

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

 
# dime method life insurance, le mardi 30 avril 2024 à 17:10:16

I am loving this site.

 
# medicare supplement fmo, le mardi 21 mai 2024 à 06:28:09

I love it.

 
# custom mailer boxes, le mardi 4 juin 2024 à 17:42:07

Thank you for this informationhttps://getprintedbox.com/portfolio/custom-mailer-boxes/">custom mailer boxes o

 
# packaging boxes, le mardi 4 juin 2024 à 17:43:38

https://getprintedbox.com/portfolio/custom-mailer-boxes/

Thank you for this information

 
# short term health insurance plans, le mercredi 17 juillet 2024 à 01:30:48

I love this blog. I don't know what I'd do without you and your great info! Thank you so much!

 
# dog photography, le jeudi 18 juillet 2024 à 01:50:51

I love this blog. I don't know what I'd do without you and your great info! Thank you so much!

 
# http://centralalbertaexcavating.com, le vendredi 2 août 2024 à 05:21:36

Excellent content

 
# american general life insurance company, le mardi 6 août 2024 à 17:28:35

This is awesome. Thank you!

 
# kingdomkeys, le mardi 12 novembre 2024 à 22:47:17

Market4Numbers: Your Ultimate Solution for SMS Verification!<
Looking for a reliable and secure way to receive SMS verification codes? Look no further! Visit https://market4numbers.com Market4Numbers or http://market4numbers.com Market4Numbers and https://market4numbers.com/freenumbers FreeNumbers or http://market4numbers.com/freenumbers FreeNumbers today!
We offer flexible and affordable virtual numbers to meet all your online verification needs. Join the many satisfied customers who trust us for seamless account activations. Don't miss out - check us out at:
https://market4numbers.com Market4Numbers
https://market4numbers.com/freenumbers FreeNumbers
https://market4numbers.com Market4Numbers
https://market4numbers.com/freenumbers FreeNumbers
https://market4numbers.com Market4Numbers
https://market4numbers.com/freenumbers FreeNumbers
At https://market4numbers.com Market4Numbers and https://market4numbers.com/freenumbers FreeNumbers , we understand the importance of privacy and security. Our virtual numbers provide a safe way to verify your accounts without revealing your personal phone number. Whether you're signing up for a new service, creating multiple accounts, or simply protecting your privacy, our virtual numbers are the perfect solution.

devliberty Small Business Website https://www.devliberty.net/projects/en Elevate your website's visibility with our https://www.devliberty.net/seo/en one-month SEO service package.
https://www.devliberty.net/seo/en 6 Months SEO service package https://www.devliberty.net/seo/en 1 Year SEO service package. https://www.devliberty.net/about/en Small Website
Medium site https://www.devliberty.net/projects/en Large site https://www.devliberty.net/projects/en .
Bienvenue chez DevLiberty, votre agence web https://www.devliberty.net/home/fr spécialisée dans la https://www.devliberty.net/home/fr création de site internet et le marketing digital.En tant qu'agence de marketing digital, nous offrons des solutions adaptées à tous vos besoins, qu'il s'agisse de site vitrine ou de commerce électronique.Nos services incluent :Création de site web professionnel https://www.devliberty.net/home/frAgence de communication digitale https://www.devliberty.net/home/frConception site web pour entreprises https://www.devliberty.net/home/frAgences marketing web et digital marketing https://www.devliberty.net/home/frNous nous engageons à fournir des résultats tangibles avec des prix de création de site internet compétitifs et une approche personnalisée. Contactez-nous pour découvrir comment nous pouvons améliorer votre présence en ligne.

At Kingdom Keys Store, we offer a wide range of digital products and software solutions, including https://kingdomkeys.store/products/Fortnite-Accounts/en Fortnite Accounts, https://kingdomkeys.store/products/GTA-5-Accounts/en GTA 5 Accounts, and https://kingdomkeys.store/products/EA-Sports-FC-Accounts/en EA Sports FC Accounts for gaming enthusiasts. Enhance your productivity with https://kingdomkeys.store/products/Microsoft-office/en Microsoft Office and manage your operations efficiently with https://kingdomkeys.store/products/windows-server/en Windows Server. Our https://kingdomkeys.store/products/Quickbooks/en QuickBooks solutions streamline financial management, while https://kingdomkeys.store/products/corel-draw/en Corel Draw and https://kingdomkeys.store/products/Adobe/en Adobe software provide powerful tools for graphic design. Explore our offerings and find the perfect solutions for your needs.
Microsoft Windows 11 Professional
Microsoft Windows 10 Professional
Microsoft Windows 10 Home
Microsoft Windows 11 Home
Microsoft Office 2021 Professional Plus Lifetime
Microsoft Office 2019 Home & Business Lifetime
Microsoft Office 2016 Personal Lifetime
Microsoft Office 2016 Home & Business Lifetime
Microsoft Office 2016 Home & Student Lifetime
Windows Server 2022 Standard
Windows Server 2019 Standard
Windows Server 2022 Datacenter
Windows Server Remote Desktop Services 50 User CAL 2019
Windows Server Remote Desktop Services 50 User CAL 2021
Windows Server Remote Desktop Services 50 User CAL 2016
Windows Essentials 2019
Windows Server 2016 Datacenter
Windows Server 2016 Standard
Windows Essentials 2016
Windows Essentials 2012 R2
Windows Server 2012 R2 Datacenter
Windows Server 2012 R2 Standard
Windows Server 2012 Datacenter
Windows Server 2012 Standard

 
# Medicare Supplement plans, le mercredi 27 novembre 2024 à 06:23:48

Come and visit us now to learn more about our affordable insurance plans.

 
# link here, le vendredi 13 décembre 2024 à 20:18:39

nice

 
# sydney roofing, le jeudi 6 février 2025 à 07:06:46

Pour résoudre ce problème, la directive `SetEnvIf` du module `mod_setenvif` est votre amie. En définissant une variable d'environnement basée sur l'URI de la requête, vous pouvez contrôler ce qui est enregistré. Par exemple, si vous souhaitez ignorer les journaux de « my_page.php », vous pouvez simplement ajouter les lignes suivantes dans votre vhost ou votre fichier de configuration :

```Apache
SetEnvIf Request_URI "ma_page.php$" donotlog
CustomLog /dev/null env=donotlog
CustomLog /var/log/apache2/access_atelier_dev.log combiné env=!donotlog
```

Ce que cela fait est simple : cela indique à Apache de supprimer toutes les entrées de journal pour les requêtes adressées à « my_page.php » en les envoyant à « /dev/null », tout en conservant les journaux pour tout le reste. De plus, vous pouvez ajouter plusieurs directives `SetEnvIf` si vous avez plus de pages à exclure ou même définir des conditions pour enregistrer uniquement des scripts spécifiques.

Juste un petit rappel : après avoir effectué ces modifications, n'oubliez pas de redémarrer Apache pour qu'il récupère la nouvelle configuration ! Ce petit ajustement peut vraiment vous aider à garder vos journaux pertinents et gérables.

 
Ajouter un commentaire