I have ASP.NET MVC 5 application with Owin.
This is my interface:
using System.Collections.Generic;
namespace MvcApp.Logging
{
public interface ILog
{
void Debug(string format, params object[] args);
void Error(string format, params object[] args);
void Fatal(string format, params object[] args);
void Info(string format, params object[] args);
void Trace(string format, params object[] args);
void Warn(string format, params object[] args);
// custom
void Write(LogType type, object properties, string message, params object[] args);
bool IsDebugEnabled { get; }
bool IsErrorEnabled { get; }
bool IsFatalEnabled { get; }
bool IsInfoEnabled { get; }
bool IsTraceEnabled { get; }
bool IsWarnEnabled { get; }
}
}
I'm using the nuget package Autofac.Mvc5.Owin to inject ILog into the constructor of the controller. This approach it works perfectly.
Owin Startup Class:
builder.RegisterType<Log>().As<ILog>().InstancePerRequest();
Now I need inject ILog interface into Global.asax.cs class and Application_Start method.
Is this possible? What do I need to setup for inject ILog?
public class MvcApplication : HttpApplication
{
// How to inject ILog here?
protected void Application_Start()
{
// I need write for example this message
ILog.Info("Application starting");
}
}
Thanks a lot