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?
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.
Windows stores event logs in the C:\WINDOWS\system32\config\ folder. Application events relate to incidents with the software installed on the local computer.
More Information. The following log files are created when an upgrade is successful: C:\Windows\Panther\Setupact. log.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With