Closed sommmen closed 2 years ago
Just confirmed that this will fault (naturally):
var someStackTraceString = " {SomeText} ---> System.FormatException: Input string w";
SelfLog.WriteLine($"Exception creating table {tableName}:\n{someStackTraceString}");
And these won't:
var someStackTraceString = " {SomeText} ---> System.FormatException: Input string was not
SelfLog.WriteLine($"Exception creating table {tableName}:\n{{0}}", someStackTraceString);
SelfLog.WriteLine("Exception creating table {0}:\n{1}", tableName, someStackTraceString);
Thank you for the contribution. It is highly appreciated. 👍
Thank you for the contribution. It is highly appreciated. 👍
Glad to be able to help.
Could you push a release for me? that way i can debug the actual exception ^^.
Here you go! Just released Serilog.Sinks.MSSSqlServer 5.7.0 https://github.com/serilog/serilog-sinks-mssqlserver/releases/tag/v439. The new version is available on nuget.org now.
Bug Report / Support Request Template
If you are opening a feature request, you can ignore this template. Bug reports and requests for assistance usually require the same basic information described below. This will help us more quickly reproduce and investigate the problem you're reporting. (If you are using Serilog.Sinks.MSSqlServerCore, that package is deprecated, please switch to Serilog.Sinks.MSSqlServer before reporting an issue.)
Pretty odd but my app runs fine when running as console app. However when running as windows service the app faults when trying to create the SQL table.
In short in the try-catch below some exception happens:
The exception gets swallowed and forwarded to the
Selflog
butSelfLog.WriteLine
causes an exception to be thrown - and this causes my entire app to crash on startup.Event logs will show this:
Looking at the code in
SelfLog.Writeline
i see:So what i'm thinking that happens is that the exception passed will cause
string.format
to fail because the string contains text that its trying to format somehow?A possible fix (that i don't know will work but wont do much harm) would be:
Get the original exception instead of this follow up exception...
(i'm using all latest packages)
[ x ] .NET Core 2.0 (i'm running net core 6) [ ] .NET Framework 4.7 [ ] .NET Framework 4.6.x [ ] .NET Framework 4.5.x OS: Windows
Foundation library has generic serilog settings:
Application specific overrides in appsettings.json: