Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Excel as log reader. How to write to log file if Excel has it open?

I've come into a position where all the existing scheduled applications write their logs to .CSV files, so that people can open them in Excel. The problem comes when someone opens a log file and just leaves it open. The applications then can't write to their logs, and by rule, they die.

So the options are:

  1. somehow get the users to open the files in Excel in a non-exclusive manner;
  2. somehow be able to write to the log despite the users' rudeness;
  3. write a kinder, gentler log reader (nope, the company runs on Excel and .csv files and they won't change);
  4. ???????

Or am I just missing a totally brainless way to deal with this?

Most of the apps are currently VBScript, but I've already managed to convert many of them to C# console apps, so answers in both styles are welcome.

like image 681
royatl Avatar asked Dec 02 '25 01:12

royatl


1 Answers

If you set NTFS permissions on the folder containing the CSV files appropriately so that your users only have read access whilst the user your scheduled tasks are running as has full access, then Excel will open the files in Read Only mode.

This will prevent Excel from holding a lock on the files and allow your logging to continue unhindered.

like image 111
Phylogenesis Avatar answered Dec 04 '25 14:12

Phylogenesis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!