command-line-api icon indicating copy to clipboard operation
command-line-api copied to clipboard

Integration for Microsoft.Extensions.Logging

Open samtrion opened this issue 5 years ago • 5 comments

In the interest of standardization, it would be an enormous advantage if System.CommandLine could offer a Microsoft.Extensions.Logging extension.

If interested, I can contribute a simple implementation.

samtrion avatar Jun 02 '20 10:06 samtrion

Have you looked at System.CommandLine.Hosting? It provides integration with Microsoft.Extensions.Logging, Microsoft.Extensions.DependencyInjection, etc.

jonsequitur avatar Jun 09 '20 19:06 jonsequitur

Yeah, I already looked at that. However, my current use case is based on an IWebHostBuilder, which makes System.CommandLine.Hosting out of the question for me.

samtrion avatar Jun 10 '20 09:06 samtrion

System.CommandLine.Hosting doesn't seem to exist anymore in the latest beta 4. I was looking at how to inject ILogger<MyType> into the handler.

JobaDiniz avatar Sep 16 '22 13:09 JobaDiniz

@JobaDiniz, https://www.nuget.org/packages/System.CommandLine.Hosting/0.4.0-alpha.22272.1 was built from the same commit 209b724 as https://www.nuget.org/packages/System.CommandLine/2.0.0-beta4.22272.1.

Oh, it's a different nuget package. I wasn't aware of that. Thanks.

JobaDiniz avatar Sep 16 '22 15:09 JobaDiniz