Disable Access Logs

This question is probably quite trivial, but I'd love it if someone could let me know if I'm doing this right!

I want to fully disable the access logs for all of my sites. When I set up the virtual hosts, I specified where to write the access logs.

If I just delete that line, will that stop the server from trying to write the log at all? Or will it still try to, but just end up writing nothing?

(I'll still keep storing error logs, but the access ones seem like a waste of CPU and they've built up to massive file sizes which is a nuisance)

Thanks for taking the time to read!

5 Replies

@Michael-Martin:

I want to fully disable the access logs for all of my sites. When I set up the virtual hosts, I specified where to write the access logs.

Presumably you're talking about a web server – but which one ? For nginx at least, you can use the directive access_log off;

Don't forget that you can also rotate, compress and delete the logs using something like logrotate(8).

If you're using Apache, you have to comment out both (1) the access log setting in the main configuration file (apache2.conf or httpd.conf), and (2) the access log setting for each virtual host. After that, Apache will not even try to write any access logs.

But why would you want to do that? Want bad guys to be able to mess with your sites without leaving any trace?

Thanks for the replies mjrich and hybinet, sounds perfect! Sorry, I forgot to say the server (It's Apache).

@hybinet - The reason is just that I've never done anything with the access logs. They're about 6GB in size at the minute, and because of that, if something did happen to the site, I'm not sure I'd ever even be able to find suspicious activity in all those thousands of entries :(

Or should I be watching the logs a little more closely?

You probably want to look into the "logrotate" program.

-rw-r--r--  1 www-data www-data  15202284 2010-03-21 05:09 access.log.3.gz
-rw-r--r--  1 www-data www-data  14730444 2010-03-28 04:44 access.log.2.gz
-rw-r--r--  1 www-data www-data  14034340 2010-04-04 04:55 access.log.1.gz
-rw-r--r--  1 www-data www-data 107838104 2010-04-07 07:47 access.log

Uncompressed, this site produces about 250MB of logs per week, which compress to under 15MB. Easier than turning off logging.

Thanks for that hoopycat! Setting it up now :)

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct