Skip to content
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

Using FormatMessageHandler throws an 'System.FormatException: 'Input string was not in a correct format.'' #27

Closed
andpewpew opened this issue Feb 18, 2023 · 1 comment

Comments

@andpewpew
Copy link

Expectation
It should be expected when using the formatted log statement the result would be the same as when using the format message handler.

commonlogger.DebugFormat(templateString, arg) == commonLogger.Debug(m => m(templateString, arg))

But that is not the case and an exception is thrown (System.FormatException: 'Input string was not in a correct format.')

Reproduce
This behaver is reproducible and can be done by modifying a test with the below:
_commonLogger.DebugFormat(templateString, arg);
replace with
_commonLogger.Debug(m => m(templateString, arg));

The test in question can be found here: https://github.com/ChangemakerStudios/Common.Logging.Serilog/blob/master/Common.Logging.Serilog.Tests/SerilogCommonLoggerTests.cs#L71

The test will fail with the following

System.FormatException: 'Input string was not in a correct format.'

Possible fix
Fixing this seems to be removing the below line
string formatted = string.Format(formatProvider, message, parameters);
found at
https://github.com/ChangemakerStudios/Common.Logging.Serilog/blob/master/src/SerilogCommonLogger.cs#L561

Outro
Last release from this project is some time ago, but I hope, my message will be seen and a fixed can be created.

Best regards

@Jaben
Copy link
Member

Jaben commented Sep 20, 2024

Fix in latest v5.0.0.

@Jaben Jaben closed this as completed Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants