0

I'm currently working with an application that uses log4net. Logging works fine when the application is started through Windows explorer, but if the application is set as the Windows shell, nothing gets logged. Are there any log4net dependencies that Windows explorer provides that are not getting consumed when the application is the shell?

Edit:

log4net gets initialized and configured in a different assembly after the application has started up via OnStartUp() (this is a WPF application).

Init and configuration of log4net looks like this:

    var assembly = Assembly.GetEntryAssembly();
    log4net.GlobalContext.Properties["ApplicationName"] = (assembly != null) ? assembly.GetName().Name : "Unmanaged";

    var log4NetFileInfo = new FileInfo("log4net.config");
    log4net.Config.XmlConfigurator.ConfigureAndWatch(log4NetFileInfo);
d.moncada
  • 16,900
  • 5
  • 53
  • 82

1 Answers1

0

It's probably a permissions issue. Log4net is designed to fail silently on error, on the justifiable grounds that no logging is better than a dead app.

Are you running with different credentials in Windows Explorer than you are in Windows shell? Are you using a relative path to find the log4net config file? Does the current working directory differ between the two ways of starting your app?

See my answer to this question, Log4net doesn't write to file, for details in enabling log4net internal debugging.

Community
  • 1
  • 1
Nicholas Carey
  • 71,308
  • 16
  • 93
  • 135
  • I do not think this is a write issue, because I have managed to get log4net working now (with a shell) by adding the configuration to my main application's assembly info, and calling GetLogger(). Though, the weird thing is that the main folder it writes to is now shown as 'null', but still has the correct logging files. – d.moncada Oct 17 '14 at 18:39