New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom format string not accepted by the message template parser #1353
Comments
Thanks for the heads-up, Eamon - sounds like a bug. Are you running 2.8.0? Cheers! |
Yeah, 2.8.0. Quite the collection actually :)
|
fix serilog#1353 Custom format string not accepted by the message template parser. Custom numeric format strings may contain plus '+' signs. That character was not recognised by the parser.
fix serilog#1353 Custom format string not accepted by the message template parser. Custom numeric format strings may contain plus '+' signs. That character was not recognised by the parser.
fix serilog#1353 Custom format string not accepted by the message template parser. Custom numeric format strings may contain plus '+' signs. That character was not recognised by the parser.
This might be a little esoteric but as I understand the message formatting is intended to follow standard .net formatting:
So in that spirit I'm raising an issue that serilog does not support using the ";" section separator for numeric formats.
likely related to #1323, #1325
I'm currently migrating some old code from Diagnostics.Trace to serilog and found a particular message was failing
The message logged a number of process metrics in a table-like fashion using alignment with the following format string:
"{0,-25} {1,10:#,##0} {2,10:#,##0} {3,10:+#,##0;-#,##0;0} {4,10:0.00}"
With serilog:
Log.Information("{0,-25} {1,10:#,##0} {2,10:#,##0} {3,10:+#,##0;-#,##0;0} {4,10:0.00}", "Process.HandleCount:", 1364, 1370, 6, 0.4398826979472);
produces
vs
Trace.WriteLine("{0,-25} {1,10:#,##0} {2,10:#,##0} {3,10:+#,##0;-#,##0;0} {4,10:0.00}", "Process.HandleCount:", 1364, 1370, 6, 0.4398826979472);
that produces the expected
The main problem is the "{3,15:+#,##0;-#,##0;0}" part which is not identified as a format string but instead rendered literally.
Actually looking at that output now I realise that it has also ignored other parts of the numeric string formats.
Currently not sure whether this is core Serilog behaviour or the sink(s). I'm currently using the File sink.
The text was updated successfully, but these errors were encountered: