0

I'm trying to redirect windows event log continuously into a file.

psloglist.exe has the -w feature (that listens for new events and outputs to console) so I tried combining it with redirection into a file like so:

psloglist -w > out.txt

It doesn't work. As new events are logged they do not show up in the file.

However, if I remove > out.txt new events do shows up in the console!

Assaf Lavie
  • 297
  • 1
  • 6
  • 17

1 Answers1

0

In general, I do not know how Windows (or this application) handles writing to files - if this were Perl, I would set the output to unbuffered.

A quick minute of Googling confirmed my thoughts.

mfinni
  • 36,144
  • 4
  • 53
  • 86
  • thanks. psloglist outputs each event immediately with the -w switch. There's no buffering that I can see. If anything it's the redirection (>) itself that might be adding the buffering, but that seems strange. If that were true it would have been the same for every command line program in Windows... – Assaf Lavie Mar 15 '10 at 18:14
  • Yes, the buffering is on writing to the output file, as explained in that link. No, not every command-line program has to exhibit the same buffering behavior. – mfinni Mar 15 '10 at 18:30
  • http://stackoverflow.com/questions/2409474/why-do-some-cmd-launched-processes-block-buffer-output-when-the-output-is-redirec Here's an explanation as to why one command-line program may buffer output, and another won't (when redirected to a file). It depends on how they are written. – mfinni Mar 15 '10 at 18:36
  • 4k buffering is indeed what's happening. But the .cmd workaround didn't fix it. Any ideas how to work around this? – Assaf Lavie Mar 16 '10 at 07:14
  • What actual problem are you trying to solve? – mfinni Mar 16 '10 at 14:52