Where is the httpd error log file on Lion?

Solution 1:

As morth pointed out, for the default Mac OS X Apache installation these are located in: /var/log/apache2/error_log.

The location can be changed in the httpd config using the ErrorLog directive, even for individual virtual hosts. Also note that if you installed another Apache besides the built-in one (like through MacPorts, or MAMP), this probably is different for you too. In that case you should have a look at the httpd.conf or equivalent for your installation.

tip: If you have Growl installed, also have a look at this 'growltail' script. I think it's great to get notified of errors while developing, without having the need to switch back to the Terminal all the time.

Solution 2:

The answers above work great for the default apache that comes pre-installed on the mac. In my case, I'm using Apache (on High Sierrra) installed via Homebrew. Here's the procedure I used to locate my error log:

>ps -ef |grep httpd

This gives an output with lines like this:

502 10587 10586   0 11:11AM ??         0:00.00 /usr/local/opt/httpd/bin/httpd -k start

That gives you the location of the httpd executable. Now run:

>/usr/local/opt/httpd/bin/httpd -V

Substituting in the location of your httpd executable. You'll get something like this (shortened)

Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/usr/local/Cellar/httpd/2.4.29_1"
 -D SUEXEC_BIN="/usr/local/opt/httpd/bin/suexec"
 -D DEFAULT_PIDLOG="/usr/local/var/run/httpd/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="/usr/local/etc/httpd/mime.types"
 -D SERVER_CONFIG_FILE="/usr/local/etc/httpd/httpd.conf"

So the "DEFAULT_ERRORLOG" is in logs/error_log - but relative to what?

Now open the "SERVER_CONFIG_FILE"

There, I found two entries that might be helpful:

ServerRoot "/usr/local/opt/httpd"
ErrorLog "/usr/local/var/log/httpd/error_log"

So in some cases the DEFAULT_ERRORLOG might be relative to ServerRoot. In my case though, there was an ErrorLog explicitly specified (second line) and that's where my errors are going.

Solution 3:

Is /private/var/log/apache2/error_log what you are looking for?

Solution 4:

The Error Log is located at: /var/log/apache2/error.log

This is for Lion...

Solution 5:

It's normally /var/log/apache2/error_log but...

Note that there's certain types of errors which can occur before apache starts logging, which might lead you to believe that you're looking in the wrong place. If you seem to be having trouble starting apache, and it's not logging any new errors, try doing:

sudo bash -x /usr/sbin/apachectl -k start

or try

sudo apachectl -e debug

or bypass the apachectl script and try just

sudo httpd -k start