Using Log4Net During Application Installation

I am having problems with how I can use logging in my setup / install project.

I have Log4net running for installed applications, but I cannot register the installation and uninstallation process.

My main problem is with the log configuration file. I suppose this is a little chicken / egg scenario - I was not able to capture the newly installed log file?

I have a method that finds the root directory of my application using - AppDomain.CurrentDomain.SetupInformation.ApplicationBase and I usually use this to find the logging configuration file. However, this directory during installation is not located where it is installed (obviously), it is located somewhere in the Windows file system.

Does anyone have any ideas?

+3
source share
2 answers

Consider configuring log4net in code, rather than using a file or saving the configuration as a file resource of your custom actions assembly and using overloading XmlConfigurator.Configure(Stream configStream).

Of course, if you want to reuse the application configuration, this is not a clean solution.

Also check out this question:

Log4net clean code configuration with filter in C #

+2
source

When you run MSI, you are tied to msiexec logging mechanisms (which is not as convenient as log4net).

+1
source

Source: https://habr.com/ru/post/1733555/


All Articles