tags:

views:

20

answers:

1

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  A: 

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

Stefan Egli