Skip to content

Log file command setting and logging via DI #278

Answered by phil-scott-78
duncansmart asked this question in Q&A
Discussion options

You must be logged in to vote

I created a demo app with this approach and pushed it here - https://github.com/phil-scott-78/spectre.console/tree/serilog-example/examples/Cli/Logging.

My chief concern is that if someone is logging outside of a command, then we won't have access to the command settings for that value. Biggest concern there would be a failure in Program.cs with configuring the command line parser and other bootstrapping code. It will log, just to a default filename.

Love some feedback on if this approach seems solid to you, @duncansmart. This is an excellent question about a common scenario, so I'd like to merge it into the main branch as an example for others in the future.

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by duncansmart
Comment options

You must be logged in to vote
1 reply
@phil-scott-78
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants