Scott Gartner
Scott Gartner

Reputation: 872

Serilog - Warnings for missing parameters

Just starting using Serilog and already I see log entries in the code where people have modified the output format string and lost a parameter. It would be nice to have a flag where it logged an extra warning when there are more parameters than there are slots to fill in the format string. For example:

log.Warning("{firstParam:l} {secondParam}", test, test1, test2);

Or vice versa:

log.Warning("{firstParam:l} {secondParam} {thirdParam} {fourthParam}", test, test1, test2);

At least this last one outputs an empty element for fourthParam. The first one could also output an element like "missing1" : "test2Value".

Or is there a way to get this to happen, but I haven't seen it yet?

Upvotes: 3

Views: 614

Answers (1)

Ruben Bartelink
Ruben Bartelink

Reputation: 61875

@Robin Sue's got you covered with the wonderful Serilog Analyzer.

The other thing is to turn on the SelfLog so you find ones that slip through.

Having said all that, I'm not sure if either mechanism provides a facility for complaining about too many - I'd say that's well worth logging an Issue on the GitHub around to at least discuss the options around.

Upvotes: 1

Related Questions