c# - Common log4net logging for different instances of a dll -


I'm having trouble doing the login-innet the way I want to work. I have a class library Library.dll which is used by mine.exe and third party applications other .exe. I have another class library that is used for both Itil.dll and Mine.exe and Library.dll.

Mine.exe and others Exe runs in parallel and I should use the same logfile as two examples of the library, it should be different than the logfile of mine.exe. Util.dll should be logged into the Library.dll logfile, when called from Library.dll, and the Mine.exe logfile is called from Mine.exe.

Edit: I think it was a bit difficult to follow, this is how I want to work:

To mine.exe Logs my.log
other.xa does not log anything (third party application)
my .exe - & gt; Library.dll log in C: \ Library.log
Other. Exe - & gt; Library.dll log in C: \ Library.log
Mine.exe - & gt; Login to Util.dll my.log
Mine.exe - & gt; Library.dll - & gt; Util.dll log in C: \ Library.log
Other Exe - & gt; Library.dll - & gt; Util.dll log in C: \ Library.log Other Exe does not call Util.dll directly.

At first I tried to load a custom log4net configuration in Library.dll, using:

  log4net.config.xmlConfigurator.Configure (new fileinfo ( "Library.log4net.config"));   

But as a result, Mine.exe is also entering the Library.dll logfile.

Then I tried to add the following assembly attribute to Library.dll:

  [Assembly: log4net.Config.Repository ("Library")]   

That log was kept separate, but after that Util.dll was logged in the mine.exe logfile whenever it is called from library.dll, I think I have itil.dll in the bay I can use the repository ("Util") in AliasReposity ("Util", "Library"), Library.Dll and Mine.exe in AliasReposity ("Util", "Mine") but I actually have many

/ Andreas

I do not share the log files honestly. If you enter a file from two processes, then there are all threading issues that you can get, usually a log4net instance will not be able to log in if another is different, then the log entries are missing from it would cause. If they are in the same log file, then you should snatch the process name in the log format so that you can know the source. Since the conference seems complex, I usually do the following:

  • Refer each process to the same log4net.
  • Create a log4net configuration section in process1.exe.config and process2.exe. Config Differently
  • Add the file appenders to process1.exe.log and process2.exe.log in each config.

    You get two files for two processes but it is easy to manage. You can get the log file viewers who can display both logs simultaneously (though I can Do not use the approach) like:

Comments