Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best location for exception log files (Windows)

The question where exception logs should go has been discussed here once or twice (or more), and one of the recommendation was that the application should never write to the installation folder.
However, if I put the logs somewhere in %appdata%, this means that each user has its own set of logs. I'd prefer having all logs at a single location.
In one of the last MSDN mag issues, having a separate sub folder for logs in the installation folder (e.g. %programfiles\myapp\logs) was called a valid exception from the rule. Of course, the ACL for this folder must be set up accordingly.
Is having a log folder in the installation folder common practice or an absolute no-go? Where do you put your exception logs?

Edit:
In fact, we are using log4net, so the location and type of logging is completely configurable. However, I want to have a reasonable default. I prefer having a file over the event log. For most users, a file is much easier to handle than the event log.
However, let's assume that I want to have files. Is it okay to have a log folder in the installation folder?

like image 758
user57474 Avatar asked Jan 21 '09 15:01

user57474


People also ask

Where should log files be stored?

Logs are stored as a file on the Log Server. A separate folder is created for the logged events each hour. The log files are stored by default in the <installation directory>/data/ storage/ directory on the Log Server.

What is the file path for the Windows Logs?

Windows stores event logs in the C:\WINDOWS\system32\config\ folder. Application events relate to incidents with the software installed on the local computer.

Where are Windows upgrade log files stored?

More Information. The following log files are created when an upgrade is successful: C:\Windows\Panther\Setupact. log.


2 Answers

For windows, use the event log. It's pretty easy to create your own log or you can just add your messages to one of the standard ones.

This has the benefit that nearly every tech (and programmer) on the planet expects something to show up in the event log when things aren't going right.

like image 105
NotMe Avatar answered Sep 20 '22 12:09

NotMe


For logging to a common file without special ACLs, use something like

string saveFolder = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\MyCompany";

which references the folder in

C:\Documents and Settings\All Users\Application Data\MyCompany

on XP, and something like

C:\ProgramData\MyCompany

under Vista. You'll need to verify that the folder exists at some point - perhaps at application startup.

like image 34
Mike Avatar answered Sep 20 '22 12:09

Mike