Registering standard LoggerFactory : ILoggerFactory implementation
This commit is contained in:
parent
58468e9509
commit
c720364d0e
|
|
@ -51,8 +51,8 @@ namespace Microsoft.AspNet.Hosting
|
|||
|
||||
yield return describer.Instance<IApplicationLifetime>(new ApplicationLifetime());
|
||||
|
||||
// TODO: We expect this to be provide by the runtime eventually.
|
||||
yield return describer.Instance<ILoggerFactory>(new NullLoggerFactory());
|
||||
// TODO: Do we expect this to be provide by the runtime eventually?
|
||||
yield return describer.Singleton<ILoggerFactory, LoggerFactory>();
|
||||
|
||||
yield return new ServiceDescriptor
|
||||
{
|
||||
|
|
@ -76,38 +76,5 @@ namespace Microsoft.AspNet.Hosting
|
|||
yield return describer.Instance<IDataProtectionProvider>(DataProtectionProvider.CreateFromDpapi());
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Temp workaround until the runtime reliably provides logging.
|
||||
// If ILoggerFactory is never guaranteed, move this fallback into Microsoft.AspNet.Logging.
|
||||
private class NullLoggerFactory : ILoggerFactory
|
||||
{
|
||||
public ILogger Create(string name)
|
||||
{
|
||||
return new NullLogger();
|
||||
}
|
||||
}
|
||||
|
||||
private class NullLogger : ILogger
|
||||
{
|
||||
public bool WriteCore(TraceType eventType, int eventId, object state, Exception exception, Func<object, Exception, string> formatter)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public IDisposable BeginScope(object state)
|
||||
{
|
||||
return NullScope.Instance;
|
||||
}
|
||||
}
|
||||
|
||||
private class NullScope : IDisposable
|
||||
{
|
||||
public static NullScope Instance = new NullScope();
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// intentionally does nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -36,5 +36,10 @@ namespace Microsoft.AspNet.TestHost
|
|||
{
|
||||
get { return new FrameworkName(".NETFramework", new Version(4, 5)); }
|
||||
}
|
||||
|
||||
public string Configuration
|
||||
{
|
||||
get { return "Test"; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue