tags:

views:

71

answers:

2

I'm having trouble seeing how I can use logging in my setup / install project.

I've got Log4net working on installed applications, but I can't seem to log the install / uninstall process.

My main problem is with the logging config file. I suppose it's a bit of a chicken/egg scenario - theres no way for me to grab the just-installed logging file?

I have a method that finds the root directory of my app, using - AppDomain.CurrentDomain.SetupInformation.ApplicationBase and i normally use this to locate the logging config file. This directory however, during install, is not where it is installing (obviously) it is somewhere within the windows filesystem.

Does anybody have any ideas to this?

+1  A: 

When executing MSI's you are bound to msiexec's logging mechanisms (which is not as friendly as log4net).

Otávio Décio
in other words, it's impossible?
serhio
Oh man, impossible... nothing is impossible.
Otávio Décio
I mean, log4net is not supposed to be used with setup applications.
serhio
Impossible? No. But if you want log4net-like capabilities during an install, though, you'll have to write your own custom action(s) to do it. Like Otavio says, MSI's native logging leaves a lot to be desired.
DaveE
+1  A: 

Consider configuring log4net in code and not using a file or storing the configuration as a file resource of your custom action assembly and using XmlConfigurator.Configure(Stream configStream) overload.

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

Also checkout this question:

log4net pure code configuration with filter in c#

João Angelo
I've basically created a "basicLogger" that, if the log4net.config file is not found, it uses an embedded resource config file, and just writes to c:\ drive... not ideal, but it works.
alex