什么是创建一个日志在log4net的一类的每个实例的最佳方法? [英] What is the best way to create a log for each instance of a class in log4net?
问题描述
我们有一对夫妇在每个系统中的同一类的长寿命的对象。只有约5或6,它们是外部系统连接。我希望每个这些实例拥有自己的文件,他们可以登录。
We have a couple of long lived objects each of the same class in the system. There are only about 5 or 6 and they are connections to outside systems. I want each of those instances to have their own file that they can log to.
什么是做到这一点的最好方法是什么?我只看到现在编程将记录仪作为答案
What is the best way to do this? I can only see adding loggers programatically as the answer right now.
更新:
我想,因为如果我添加到一个新的连接,以避免使用配置文件不同的远程主机的话,我想它的日志输出去连接后命名的文件,而无需先砍在配置文件中各地。如果它被自动地做这将是很好。我不知道,也许这可以在配置文件可以实现一次关闭,你不需要每次编辑它。
UPDATE: I want to avoid using the configuration file because if I add a new connection to a different remote host then i want its log output to go to file named after the connection without having to first hack around in a config file. It would be nice if it was done automagically. I don't know maybe this can be achieved in a config file once off and that you don't need to edit it everytime.
推荐答案
最好的答案是programatical记录,我经历了同样的问题去了,看见它作为唯一的解决办法。
The best answer IS programatical logging, i went through the same problem and found it as the only solution.
有关更多帮助检查这个问题(我的)
StackOverflow的问题发表我
For more help check this question (mine) StackOverFlow Question posted by me
和我的事情你的,我的问题是一样的,动态的记录器,重新创建记录器,在运行时配置记录仪和所有的东西:)
and i thing yours and my problem are the same, dynamic loggers, re create loggers, dispose loggers and all that stuff at runtime :)
如果任何更多的问题,可能会问,会很乐意帮助,因为我已经通过所有的了:)
if any more questions, do ask, will be glad to help since i have gone through all that :)
这篇关于什么是创建一个日志在log4net的一类的每个实例的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!