0

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?

Jost
  • 5,948
  • 8
  • 42
  • 72
Ondro Tadanai
  • 123
  • 2
  • 12

1 Answers1

0

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.

Peter
  • 27,590
  • 8
  • 64
  • 84
  • Can filter manage that customers logs will be in customer directory and application log will be in Logs/log.txt file? – Ondro Tadanai Mar 22 '15 at 09:25
  • Yes you can, assumed you can set a property on what customer is running. Add an appender for each customer and filter only the messages for that customer. If no property is set, you can log in the general application log. – Peter Mar 22 '15 at 09:33
  • Number of customer is not known yet (something around 500), i dont think its possible to change app.config for each one. My first opinion was to have ILog instance for applocation logging and each instance of customer class will have a ILog member for customer logging, do you think its possible to configure it like this? `AppLog.Debug("creating cust1"); var cust1 = new Customer(); cust1.Log.Debug("cust1 logstart"); ` – Ondro Tadanai Mar 22 '15 at 10:10