Search code examples
c#log4netcommon.logging

Common.Logging - More Ilog instances


I'm developing a Windows service. I use commong.logging & log4net. I have properly configured my app.config and I'm logging application events & exceptions to a log file. Now I have got new requirements. Every customer needs his own log file in his customer directory. Also I want to use a global log file, like I do it now.

How to setup this configuration? I suppose I need my global logging configuration in app.config (as i have it now), the ILog instance should be member of customer class and I need to set it up by code?


Solution

  • You need a way to know how to filter on a specific customer. A way to do this is by setting a property customer on your thread and than filter in the appenders on the specific customer (log4net.Filter.PropertyFilter). Assumed that all customer code is running in one service.