1

I have 2 services that have log4net references and XmlConfigurator set to watch in the AssemblyInfo.cs.

If I run both services on my local machine, both are running from separate directories with Copy Local set to the Log4Net dll. Both services log fine.

When I push the services to production, they both sit in the same directory (I have no say in this), and the behaviour I am seeing is strange. If one service is started, it logs fine, but the other service does not log at all. Stranger, if I shut both of them down and start the second, it logs fine, but the first one does not log.

I am assuming that the services can only log one at a time, but this doesn't seem to make any sense since they are separate services.

Does anyone have an idea of what could be going on here?

Mark Kadlec
  • 8,036
  • 17
  • 60
  • 96
  • Are the services trying to log to the same file? – sgmoore Aug 16 '13 at 18:05
  • @sgmoore, good question, no, separate files. The ADO appender is logging to the same table though. – Mark Kadlec Aug 16 '13 at 18:09
  • Probably best to enable Internal logging on log4net. (See http://stackoverflow.com/questions/756125/how-to-track-down-log4net-problems for one way to do this) – sgmoore Aug 16 '13 at 18:13

2 Answers2

1

It would appear the first process is locking the DLL and preventing the other one from loading the same file into its app domain. Just for fun, have you tried making a copy of the DLL, change the name, then have the second service reference that other file? Perhaps something like:

    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net2nd" />
The other other Alan
  • 1,868
  • 12
  • 21
  • That's a good suggestion, but I'm hoping to avoid having 2 separate dlls with different names (although it might come to that). I'm confused why the log4net dll would be locked by the first process, is that possible? – Mark Kadlec Aug 16 '13 at 17:47
1

Not that you are looking to change .dll files on the fly, but you might want to look into loading the log4net .dll using the Shadow Copy service. I got the idea from this answer: https://stackoverflow.com/a/226589/151234

Some helpful hints can be found here. It's similar to how ASP.NET works when you drop in a new .dll file.

Community
  • 1
  • 1
Brendan Hannemann
  • 2,084
  • 1
  • 18
  • 33