c# - ASP.Net5 get current Ilogger -
i using interfaces happens use microsoft.extensions.logging.ilogger
.
i want know how instantiate 1 interface using ilogger
noting iloggerfactory
in
here have done don't know if right or not
services.addsingleton<iservicecache, cache>( iapp => new cache(_loggerfactory.createlogger("debug")) );
or can do:
#if debug services.addsingleton<ilogger>(_loggerfactory.createlogger("debug")); #else // here add logger release or whatever other mode #endif
the ilogger injected automatically in dependent services. should enough:
services.addsingleton<iservicecache, cache>();
Comments
Post a Comment