Helpful Information
 
 
Category: Apache Development
disable logs

how do i disable access and/or error logs?

Access logs can be turned off simply by commenting out the CustomLog directive.

Error logs don't seem to turn off quite that easily, for those you can set your ErrorLog to /dev/null.

>> how do i disable access and/or error logs?

That's extremely bad practice, why you wanted to do this in the first place? If the log grows too large, just rotate it often.

>> for those you can set your ErrorLog to /dev/null

This also is not the right approach since you are sending every request to /dev/null (slow). Instead, start here -> http://httpd.apache.org/docs/mod/core.html#loglevel and set the loglevel as high as possible like emerg.

I had considered an 'editorialized' version of my post originally, but figured.. hey.. if somebody wants to shut off their logs... whatever...


This also is not the right approach since you are sending every request to /dev/null (slow).

Hmm?
Writing requests to /dev/null is faster than logging them to a the log file.

Let's assume for a moment that the original poster actually has a good reason for asking this question (do we have any reason to believe otherwise?), and our obligation here is to actually answer their question. If sending the errors to /dev/null is supposedly wrong, what would be better?

Just one more note on writing to /dev/null...

on my linux box:


[\u@\h \W]$ time cp /proc/kcore /tmp
7.52s real 0.10s user 2.09s system
[\u@\h \W]$ time cp /proc/kcore /dev/null
1.19s real 0.03s user 0.82s system
[\u@\h \W]$


I'd say writing to /dev/null is a bit faster.

>> Writing requests to /dev/null is faster than logging them to a the log file

I don't question that. But I wasn't comparing the speed of logging to /dev/null or a file. Who in the world doesn't know sending to /dev/null is faster?

I said slow because that is sending unneccessary log with loglevel of info or higher, it doesn't matter where it sends to as that's not the issue here.
The right approach as I said, is to send only emerg or higher. When you set the loglevel to emerg, your log almost always empty because Apache doesn't send anything lower than emerg. The right approach is to DO NOTHING instead of sending it to whereever.

We have 3 choices here:
1) send everything to a file
2) send everything to /dev/null
3) just send emerg or higher to a file
note, (3) almost sends nothing or do nothing.
If Apache really needs to send emerg, is server has got a huge problem.

Originally posted by freebsd
>> how do i disable access and/or error logs?

That's extremely bad practice, why you wanted to do this in the first place? If the log grows too large, just rotate it often.

>> for those you can set your ErrorLog to /dev/null

This also is not the right approach since you are sending every request to /dev/null (slow). Instead, start here -> http://httpd.apache.org/docs/mod/core.html#loglevel and set the loglevel as high as possible like emerg.

ok, that's right, i won't do that on a production server...

i'm doing this since i'm using Apache for PHP development
on my client (a mdk-linux PC) and because I have little memory and I have to run KDE2 too...

PHP prints errors into the web page so i don't need to tail -f error_log

redirecting errors to /dev/null or set LogLevel to
emerg both works for me

thanks to all for your help!

Hi
just read the thread and the Apache docs.
(I'm on Windows therefore i can't send data to dev/null.)
I modified my httpd.conf like that:

# No AccessLog
SetEnvIf Remote_Addr "0\.0\.0\.1" log
CustomLog logs/access.log common env=log


This works very well, but i wanted to know, if there are some issues (security, etc...?) when doing so.

Any help appreciated since i'm new to apache.

TIA










privacy (GDPR)