I wrote a simple MS Word AddIn in Visual Studio 2013, and I would like to be able to log events, preferably in the Windows Event Viewer. It seems that I will encounter resolution problems if I try to create a new event source for my application. I am looking for the simplest approach that allows me to register events from my VSTO, which does not violate the rules of good programming.
Option 1: Use VSTO 4.0 Source
I can see from the MSDN documentation on the Event Log for Office Solutions , which:
You can use the Event Viewer on Windows to view exception messages that will be caught by the Visual Studio Tools for Office environment when you install or uninstall Office solutions. You can use these messages from the event logger to solve installation and deployment problems.
These events are logged using the VSTO 4.0 source. Can I use the VSTO 4.0 source to log errors from my own AddIn, or is this considered bad practice?
Edit:. The answer from Yevgeny Astafyev and what I read in other places seems to be a bad approach, since the source of VSTO 4.0 should only deal with the management of AddIns, and not AddIns themselves. Answers to other questions also did not recommend the use of "general" sources.
Option 2. Create a boot application that will be included in the installer
Alternatively, I could include a simple boot application that creates the source during installation, but I donβt see how to add my own prerequisites using the installation settings in Properties> Publish to Visual Studio. It can be done? Is there any other way to do this? I would prefer not to create InstallShield Windows Installer , since in any other case, the default installer works well for my purposes. Overkill seems to create a complete installer just to get an event log.
Edit: It still seems that there is no easy way to do this, although it is not too difficult to create an installer by following the related instructions.
Option 3: use the registration framework and enter the file
The third option is to use log4net or a similar logging structure and configure File Appender to write to the file.
Initially, I didnβt really want to implement file logging, because: a) My application was not logged very often, and b) I wanted to avoid having the log files scattered in different places that are difficult to find.
Edit: This is the option I made so far, since it required the smallest configuration and is adaptable if my registration requirements change in the future.