How can I save log file whose name is logger name in log4net?

家住魔仙堡 提交于 2019-12-24 10:46:26

问题


In log4net we can use ILog logger = LogManager.GetLogger(typeof(something)); to create logger.

But I want to save log with the name of "something" in GetLogger() method. How can I do this?


回答1:


log4net does not support this by configuration. If you have only a few classes then you can configure an appender per class but depending on the number of classes your configuration file will get quite big.

You could of course write your own appender with that functionality but you may want to consider to do log to a database instead. This way you can filter your log messages in any way you see fit.


Edit: You could also create the appenders programmatically per logger. But I would not go for it...



来源:https://stackoverflow.com/questions/3742071/how-can-i-save-log-file-whose-name-is-logger-name-in-log4net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!