If I add logging services to container (in ASP.NET 5 RC1):
services.AddSingleton<ILoggerFactory>();
services.AddSingleton(typeof(ILogger<>), typeof(Logger<>));
//or just services.AddLogging();
Then I can use Logger in my app layer:
class MyAppLogicService
{
public MyAppLogicService(ILogger<MyAppLogicService> logger)
{
logger.LogInformation("Hey");
}
}
But in this case my logger.LogInformation() events will mix with unimportant framework information events (according to devs up to 10 per request!).
ASP.NET 5 documentation states:
It is recommended that you perform application logging at the level of your application and its APIs, not at the level of the framework. The framework already has logging built in which can be enabled simply by setting the appropriate logging verbosity level.
What does this mean? Does it mean that using ILogger/ILoggerFactory in client code (app logic) is not recommended?
What is an elegant solution to separate app level logging from framework level logging? For now I'm using Serilog and filtering by ContextSource, but this is far from elegant...