The page describes what the example configuration does, however, it is not clear how to configure other logging targets (e.g. EventSource or Debug). So more examples or a in-depth explanation would be awesome.
โ Do not edit this section. It is required for docs.microsoft.com โ GitHub issue linking.
The first code sample shows how to do that:
public static void Main(string[] args)
{
var webHost = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.ConfigureAppConfiguration((hostingContext, config) =>
{
var env = hostingContext.HostingEnvironment;
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json",
optional: true, reloadOnChange: true);
config.AddEnvironmentVariables();
})
.ConfigureLogging((hostingContext, logging) =>
{
logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
logging.AddConsole();
logging.AddDebug();
logging.AddEventSourceLogger();
})
.UseStartup<Startup>()
.Build();
webHost.Run();
}
Thanks for your quick feedback. Maybe, I did not explain myself clearly. The examples show how to hook up configuration that is located elsewhere (appsettings.json or environment variables) and also show an example of the appsettings configuration, but it does not show which flags can be set in those configuration files and which are available in general. This was something which I expected from the Configuration chapter but which was not available there.
We often list/explain options (usually mirrored content from the API docs), but we'd be hard pressed to doc all of the options for every framework feature. Also, there's generally ๐ a lot of engineering churn ๐ with options.
One way to handle this is to link to the options in the API browser. Today, it's often a reader-unfriendly process to get to them. For example, take the Console Provider ...
In the Console provider case, we could link https://docs.microsoft.com/dotnet/api/microsoft.extensions.logging.console.consoleloggeroptions. The reader can select their version. We wouldn't need to list/explain every one. Engineering can modify them each release with reduced doc churn.
@lefe For the two that you asked about IIRC, I don't think there are options to configure (but you should look to make sure). For the rest of the providers, I'll link their options API docs.
Most helpful comment
We often list/explain options (usually mirrored content from the API docs), but we'd be hard pressed to doc all of the options for every framework feature. Also, there's generally ๐ a lot of engineering churn ๐ with options.
One way to handle this is to link to the options in the API browser. Today, it's often a reader-unfriendly process to get to them. For example, take the Console Provider ...
In the Console provider case, we could link https://docs.microsoft.com/dotnet/api/microsoft.extensions.logging.console.consoleloggeroptions. The reader can select their version. We wouldn't need to list/explain every one. Engineering can modify them each release with reduced doc churn.