I'm doing infrequent development with Apache/PHP on my Windows machine so I've opted to run apache as a console process instead of a service. It would be nice if errors could be logged to the console window instead of a logfile so I can see them immediately. Can this be done somehow? It doesn't seem that apache has such a capability built in and I can't find a mod that would do this either.
Yes it can.
Edit your httpd.conf
file to pipe the output of the error log to your console window with this directive:
ErrorLog "|more"
Just wanted to update this question with an answer that may be plaguing a bunch of people.
Scenario:
- Running an apache2 docker container
- Want output of
docker run <container_id>
to show logs
Without talking too much about docker, the relevant command I ran to run apache and show logs at the same time:
/usr/sbin/apache2 & tail -f /var/log/apache2/*
You can modify this as you need (I am using debian:jessie
image). As mentioned in a comment above, you have get tail
for windows and I believe the &
operator should work in Windows as well (not sure about this).
This command will block your shell and keep sprouting stuff from your logs...
Hope this helps someone
I'm not sure if apache will let you do that, but have you tried using:
tail -f /the/apache/logfile.log
?
That should let you watch the log in realtime (assuming you aren't buffering it or anything)
EDIT:
Since this is a windows machine, the same thing can be done using TextPad (just have it to auto-reload the log file on change). It will function the same as tail
tail
can be compiled for that too. Well, it's an option, although I'd prefer if there was just one console window. Hmm... then again I could probably get away with setting it up as a service and then creating a batch file to start it, followed by tail
and then stopping the service. Or just write my own starter/reader/stopper program in C#, that's easy. Still - maybe a more elegant solution is available? –
Forta For windows you can use httpd.exe -X
-X Run httpd in debug mode. Only one worker will be started and the server will not detach from the console.
To make Apache httpd log errors to your console on Windows, put the following line in your httpd.conf
:
ErrorLog "|C:/Windows/System32/more.com"
Then invoke httpd with the -X
flag: httpd.exe -X
This seems to work as of 2024-07-22 on Windows 10 using cmd
and httpd-2.4.62-240718-win64-VS17.
The more.com
program was suggested by François Breton in a comment.
The -X
option was suggested by aLx13 in this answer.
© 2022 - 2024 — McMap. All rights reserved.