开发者

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

开发者 https://www.devze.com 2023-01-17 03:58 出处:网络
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 th开发者_Go百科

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 th开发者_Go百科is?


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...

0

精彩评论

暂无评论...
验证码 换一张
取 消