1

I've had a problem with my IIS that I could only log daily: Why does the IIS only write logs once per day?

The answer helped a lot, BUT I've run into a problem with it. In essence: I manage to configure it so that I get up to hourly logs. But when I say "create no new file" to get a continuous stream of logfile entries.......the file is created and stays at 0 bytes. After 30 minutes I changed back to hourly and.....suddenly the file got 300 KB of data into it.

Thus my question is, how can I get the IIS to log continuously in a permanent stream, so that every new log entry is immediately written into the logfile?

IIS Version: (10.0.14393.0)

Thomas
  • 405

1 Answers1

2

The command to immediately flush the IIS buffer is :

netsh http flush logbuffer

You may loop over it using a batch file.

The following example .bat file flushes the log file every second:

@echo off
:loop
  netsh http flush logbuffer
  timeout /t 1 > NUL
goto loop
harrymc
  • 480,290
  • so that I get it right: regardless waht I do...for examlpe if I put it down as daily logs, if I want a continuous stream I don't have any configuration option any longer, but instead need to flush the buffer manually? – Thomas Jul 21 '22 at 12:28
  • That will get a log that is up to date to the second, and you don't need to force IIS to do something that it's not designed to do. – harrymc Jul 21 '22 at 12:41
  • Is there any known reason as to why a continuous log is no longer configurable? (in the way older versions I used in the past it was default that it wrote the logs either immediately or with 1-2 minutes delay not "only" when he creates a new file) – Thomas Jul 21 '22 at 12:44
  • Microsoft changes stuff with every new version and we must adapt. It seems like "create no new file" doesn't work any more. You can do a bug report using the Feedback Hub, and maybe this will be fixed in the future. – harrymc Jul 21 '22 at 12:48
  • thanks. Then I would guess the way to go (problem workaround) is either "no new logfile" or a daily one and your flush command to be run at a minute or hourly base. is there any downside to the command eing used repeatedly? – Thomas Jul 21 '22 at 12:55
  • No bad effect that I know of, except the time taken by flushing (should be unnoticeable). – harrymc Jul 21 '22 at 12:58
  • 1
    tnx. accepted your answer. I wonder only if microsoft doesn't run into the same problems.......at least if they use IIS for their own web servers ..... but that is already too off topic fo rhere. – Thomas Jul 21 '22 at 13:01
  • on the server the flushing works with "ok" logfile doesnt get written though only at the full hour (I'm so trying not to shout "Microsoft" like "Kaaahhhnnnn" in star trek now) – Thomas Jul 21 '22 at 21:38