1

I am registered Nlog in my Container builder like below:

builder.Register( x=> LogManager.GetLogger("LoggerName")).As<NLog.ILogger>();

And my Controller constructor like below:

       public AccountController(NLog.ILogger logger)
    {
        _logger = logger;
    }

How can i get resolver class name (in this case "AccountController" ) and use it as GetLogger parameter?

ramin_rp
  • 321
  • 1
  • 4
  • 14
  • 1
    Possible duplicate of [Passing in the type of the declaring class for NLog using Autofac](http://stackoverflow.com/questions/6623431/passing-in-the-type-of-the-declaring-class-for-nlog-using-autofac) – Cyril Durand Apr 26 '16 at 18:28
  • 1
    Also heavy overlap/duplication with these questions: http://stackoverflow.com/q/29125250/8116 , http://stackoverflow.com/q/24811956/8116 , http://stackoverflow.com/q/12589898/8116 – Travis Illig Apr 27 '16 at 03:27

1 Answers1

0

I found a nuget package, and other implementation of autofac module on github for this Purpose

Autofac.Extras.NLog

Log4Net and NLog modules for Autofac Implementation

Both solves my problem.

ramin_rp
  • 321
  • 1
  • 4
  • 14