Disable apache2 log
If you truly want to disable the logs, you must comment out any ErrorLog
and CustomLog
directives in your Apache configuration files. On Debian, these will be located in /etc/apache2/httpd.conf
and /etc/apache2/apache2.conf
(the base configuration) and then /etc/apache2/sites-available/*
(specific virtual host configurations).
You can comment them out by adding a '#' character in front of them.
Once the changes are made, run /etc/init.d/apache2 restart
for the changes to take effect.
IMO, a better solution -- since logs are often very handy -- is to install log rotate as Sergey suggested above. In Debian, run this:
sudo apt-get install logrotate
logrotate will, in its default configuration, split logs daily and compress the old ones, saving a ton of disk space while preserving the logs themselves.
Don't log certain requests in Apache access.log
The solution is to disable logging of certain requests (for example in /etc/apache2/sites-available/000-default.conf
with Debian 8):
<VirtualHost *:80>
ServerName www.mywebsite.com
DocumentRoot /home/www/mywebsite
...
SetEnvIf Request_URI "^/piwik(.*)$" dontlog
CustomLog ${APACHE_LOG_DIR}/other_vhosts_access.log vhost_combined env=!dontlog
</VirtualHost>
How to make Apache stop log some my Urls
Thanks to Nick and Tarun. I resolved my problem.
In my .htaccess
file, I add some configs:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^automate/phpfile1/(.*) ?call=phpfile1. processSomething&module=$1
RewriteRule ^automate/phpfile2/(.*) ?call=phpfile2.processSomethingElse&module=$1
</IfModule>
And in my httpd-vhosts.conf
file, I set like below:
SetEnvIf Request_URI "^/automate/phpfile1/" dontlog
SetEnvIf Request_URI "^/automate/phpfile2/" dontlog
CustomLog "logs/myapp.com-access.log" combined env=!dontlog
So, apache doesn't logging Uris :D
How to disable access logs in apache via htaccess?
Answer is big NO. You cannot control Apache logging from .htaccess unfortunately.
Disable query strings in access log
Your common
log format includes the query string in %r
(first line of request)
What you can do is to add a new log format (keep the old one for reference, no need to remove it)
LogFormat "%h %l %u %t \"%m %U %H\" %>s %b" common_no_querystring
where %m
is the method (GET/POST), %U
is the URL requested without querystring and %H
is the HTTP version for the request. This will output the same line as %r
, except the query string.
Then all you need to do is change the customlog line to;
CustomLog "logs/access.log" common_no_querystring
and you'll no longer get query strings in the log.
disable access logging for specific folder - centos 6 / apache 2.4
By default cPanel/WHM stores the access logs for the cPanel accounts (domains/sites/etc) in /usr/local/apache/domlogs/. That means that all the requests for that site are logged in that file (including the requests from folder1, folder2 etc).
You could try something like this:
Create an .htaccess file in /home/username/public_html/folder1/folder2/ with the content from bellow:
<IfModule mod_userdir.c>
UserDir public_html
SetEnvIf Request_URI "/nolog" dontlog
CustomLog /usr/local/apache/domlogs/domain.com combined env=!dontlog
</IfModule>
See if that works (basically it should allow logging but exclude the requests from the files from folder1, folder2 etc).
If that doesn't work then you could edit /var/cpanel/userdata/username/domain.com and comment the bytes_log line and the access_log line. That should completely disable access logging of http requests for that domain. You might need to restart httpd and cpanel service for the changes to take effect.
Related Topics
Delete All Files Except the Newest 3 in Bash Script
How to Limit File Size on Commit
Using Curl in a Bash Script and Getting Curl: (3) Illegal Characters Found in Url
What Is the Linux Built-In Driver Load Order
Is It Ok (Performance-Wise) to Have Hundreds or Thousands of Files in the Same Linux Directory
How to Run the Cron Job as a User Instead of Root User
Component Based Web Project Directory Layout with Git and Symlinks
Differencebetween "Var=${Var:-Word}" and "Var=${Var:=Word}"
How to Read the Mouse Button State from /Dev/Input/Mice
Loading Linux Text File into Excel Using Vba
How to Disable Socket Creation for a Linux Process, for Sandboxing
How to Increase the /Proc/Pid/Cmdline 4096 Byte Limit
Dependency Walker Equivalent for Linux
Maintain File and Folder Permissions Inside Archives