0
votes

So in a console .Net application I can watch all my log4net events stream by with (the powershell command) get-content .\log.log -Wait which is similar to the linux tail command and I assume uses FileSystemWatcher under the hood.

For some reason, whenever I have an asp.net Mvc application this will not work. To be clear, the log file IS written to. I can get-content .\log.log as many times as I want and get the most recent results, but with the -wait parameter I never see the changes scroll past.

Does anyone have any insight into what might be going on here?

1

1 Answers

1
votes

UPDATE: found a working solution for my case, not sure whether this would help you out.

Instead of using PowerShell, I downloaded win-bash and now I'm using this familiar Unix command which works perfectly for me.

tail -f access.log

I'm not that familiar with .Net programming. Could it be a working solution in your case to use win-bash project's bash.exe instead of PowerShell?


I am experiencing similar issue when trying to "tail" Apache access log in PowerShell.

Get-Content .\access.log -Wait

I noticed that when my Apache HTTP server is running, it has a handle open to acccess.log and -Wait doesn't work. Stopping HTTP server releases the handle and when I made manual changes to access.log using text editor my PowerShell window immediately reflected changes in the console.

So I assume if some other program has a handle open to the file, changes are not reflected to console. Unfortunately I haven't found a way around this issue so far.