Unique log file for each instance of class

前端 未结 4 1886
有刺的猬
有刺的猬 2020-12-14 03:07

I am currently running a windows service that creates multiple instances of a class.

At the top of the service class and every other class in my solution, I have som

4条回答
  •  执笔经年
    2020-12-14 03:46

    I have an article that might help:

    http://horth.com/blog/?p=165

    This is about changing a logfile at runtime. What you could do is pass in the file name for each instance into your log4net file. That way you could create a log file for each instance of your class. This way your config file is simple and yet you have the flexibility to create a new log file for each class instance.

    It was mentioned above that you could log to a database as well with indicators for each instance. If you don't wan to buy anything, use SQL Express which allows 10GB databases. You can even write directly to the MDF file instead of installing SQL.

提交回复
热议问题