dotnet / command-line-api

Command line parsing, invocation, and rendering of terminal output.
https://github.com/dotnet/command-line-api/wiki
MIT License
3.43k stars 384 forks source link

Integration for Microsoft.Extensions.Logging #916

Open samtrion opened 4 years ago

samtrion commented 4 years ago

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.

jonsequitur commented 4 years ago

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

samtrion commented 4 years ago

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.

JobaDiniz commented 2 years ago

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.

KalleOlaviNiemitalo commented 2 years ago

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

JobaDiniz commented 2 years ago

@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.