Reputation: 4552
I only have 32GB on my server, and the logs is eating up that space quickly. So I want to disable the logs.
I think I found where to do it, but since I'm a complete noob when it comes to server, I don't want to start changing things without being sure that they won't crash the server.
In etc/apache2/apache2.conf, I found this:
#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
# If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
and in etc/apache2/conf.d/other-vhost-access-log, I found this:
# Define an access log for VirtualHosts that don't define their own logfile
CustomLog ${APACHE_LOG_DIR}/other_vhosts_access.log vhost_combined
What do I need to do to disable the logs?
Thanks in advance
Upvotes: 2
Views: 9296
Reputation: 41
The accepted answer here is wrong. Commenting out that line does not disable the errorlog, it just reverts it to the apache2 default. From the apache2 ErrorLog documentation:
Default: ErrorLog logs/error_log (Unix) ErrorLog logs/error.log (Windows and OS/2)
In other words, this will be somewhere in the apache installation root 'logs' directory.
To disable I think you'll need to recompile without logging support (not sure if even possible), or pipe ErrorLog to /dev/null:
ErrorLog "|/dev/null"
Upvotes: 3
Reputation: 3045
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.
Upvotes: 5