Can Apache httpd be made to log errors to console instead of log files under Windows?
Asked Answered
F

5

13

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.

Forta answered 27/4, 2010 at 23:27 Comment(0)
I
10

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"
Ibnrushd answered 7/9, 2010 at 11:53 Comment(4)
Does not work on my Windows 8. It gives me error:(OS 2)The system cannot find the file specified. : AH00089: Couldn't start Erro rLog process 'more'. AH00015: Unable to open logsSurgical
Any info on a windows solution?Inhabitancy
Couldn't start ErrorLog process 'more'.Cylix
ErrorLog "|C:/Windows/System32/more.com"Gregarious
B
4

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

Bosanquet answered 25/7, 2014 at 4:43 Comment(1)
I believe this would not work correctly because when you try to stop or kill this process (or docker container) it would only stop the tail process, not apache, which would then continue to run and would fail to start next time you try to start the container.Cirenaica
S
3

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

Shed answered 27/4, 2010 at 23:33 Comment(8)
It's a windows machine, I already stated that. But I suppose 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
I like this suggestion that way you have the errors in a file and displaying on the console. But yes, tail is native to *nix not Windows, though it can be made to work in Windows, easiest solution I know is cygwinEpochal
Wow I totally glanced over the Windows part :(. I updated my answer to use TextPad, which should workShed
@Flash84x - Actually a quick google search reveals quite a few native Win32 implementation of tail, including some by Microsoft itself. Cygwin is a bit extreme for my taste. :PForta
@webdestroya - Interesting idea. I'm using Notepad++ myself, but that has this feature too.Forta
@Vilx - I generally found it as an annoyance, but it does have its uses.Shed
@webdestroya - as long as it can be set not to explicitly prompt every time there's an update, it should be fine. I might try it. :)Forta
@Vilx - "Prefs->File-> 'When files are open by another process... 'auto-reload'"Shed
P
1

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.
Polyclinic answered 19/10, 2021 at 11:14 Comment(0)
K
1

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.

Knave answered 22/7 at 19:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.