I have just recently added Microsoft.Practices.EnterpriseLibrary.SemanticLogging (v6) with SqlServer silk in my MVC 4 application.
var sqlListener = SqlDatabaseLog.CreateListener("SampleEventLogger",strConnection);
sqlListener.EnableEvents(BasicLogger.Log, EventLevel.LogAlways);
this is the code in my controller
BasicLogger.Log.Critical("ERROR CRITICAL");
It works well!
...and now the impediment :) In my MVC application I use Unity for DI and I inject into constructor ILogger interface. Because I need to use the same reference that I have registered into unity container (otherwise doesn't work) ,so I have thought that taking the RegisteredType could be the solution.
var myRegistereType = container.Resolve<ILogger>();
sqlListener.EnableEvents(myRegistereType, EventLevel.LogAlways);
but I received an error
*There is already an instance of EventSource with Guid XXX XXX XXX XXX *
Does anyone have any idea? thanks