j-maly / CommandLineParser

Command line parser. Declarative arguments support. Rich set of argument types (switches, enums, files, etc...). Mutually exclusive arguments validations.
MIT License
137 stars 30 forks source link

How to redirect log to Serilog #76

Open askids opened 2 years ago

askids commented 2 years ago

hi,

I am trying to port an existing console app written in .Net FW 4.7 to .Net Core. Previously, we were simply using Console.Writeline to write everything for logging purpose. But now, for logging, I am using Serilog with Console sink with structured json compact formatter.

When I use ArgsClass.ShowUsage() method to show available arguments, it writes to console, but in raw format and not in expected json format. Is there a way to route the ShowUsage() method output to Serilog so that it can then write it using required format.

Thanks!