views:

49

answers:

3

I have a Visual Studio project that gets installed to about half of the PCs in our company.

The application has an error logging routine that appends error messages to a text file that is kept here:

static string _appPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), Application.CompanyName);

For the most part, this works well and allows me to get to the log files on individual PCs.

It does not work everywhere. Some users have limited accounts, which do not have permissions to write to the Environment.SpecialFolder.CommonApplicationData folder.

I could modify the path to store here:

static string _newPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Application.CompanyName);

However, then when I need to collect log files, I must dig into every single user account folder on each PC to get to the logs.

What I would like to do is store these messages on our internal network. The problem with this is how to handle multiple write instances.

static string _netPath = Path.Combine(@"\\FileServer1", Application.CompanyName);

I'd like to use Messaging, but I'm not sure how to do that - or if it would be a good solution to this. Management wants me to push this update out this Friday (today is Wednesday).

What would be the easiest, most reliable method of using _netPath to store log files from some 100 PCs in our network?

Note: Please, if you reference MSDN, paste the article. We have an old Microsoft ISA firewall that is not able to pass MSDN websites. (The ISA server times out every time, and it is so frusterating! See ISA Proxy Server can't... for my unanswered question on it.)

+5  A: 

Save each pc's log file under a different name in your network folder instead of having all the pc's share the same log file.

You can use their network ID for the name or anything else you can generate automatically.

Beth
Then, if you wanted to combine them, you could have a simple server process watch this folder for changes, and anything appended to one file can be detected and written to a master log.
KeithS
A: 

What if you used a centralized service to do that? Create a simple logging webservice on an internal server somewhere and send the data to the webservice. That way only the webservice would need access to the log files, as long as everyone can touch the service. Then you can store them all in one folder or do anything you want with them.

It wouldn't have to be a webservice, of course, but that's a pretty quick and simple way, and it's the first that springs to mind. Really any centralized application that your clients can hit should do the trick.

Justin Morgan
I've got a buggy centralized service now, but I'm not sure how to quickly implement what you are saying. Got any 'non-MSDN' references or code examples?
jp2code
+1  A: 

Add the PC name to the filename too... Then you dont have all the instances writing to the same file, and when you get a support call, you can go straight to the file for the pc of the user its been logged from...

Alternatively, just use a plain WCF service (even self-hosted) to manage the writing to the file, all other machines just call the service method

You could use MSMQ via WCF too

Overflow
+1 for "I REALLY NEED TO LEARN WCF"!
jp2code