Describe the bug
Function "Error()" of Serilog.ILogger is adding the \r\n escape characters to the string.
I am currently using the following Code to send a Log Message to an HTTP endpoint.
Serilog.Sinks 2.11.0
Serilog.SInks.Http 8.0.0
Adding Http Sink to LoggerConfiguration
loggerConfiguration.WriteTo.Http(
restrictedToMinimumLevel: LogEventLevel.Information,
requestUri: "https://......",
httpClient: _serilogHttpClientFactory.Create(),
queueLimitBytes: null);
SerilogHttpClientFactory creates an Object of type "SerilogHttpClient"
SerilogHttpClient
public class SerilogHttpClient : IValue<System.Net.Http.HttpClient>, Serilog.SInks.Http.IHttpClient{
public async Task<HttpResponseMessage> PostAsync(string requestUri, Stream contentStream)
{
using var content = new StreamContent(contentStream);
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
var result = await Value.PostAsync(requestUri, content);
return result;
}
}
SerilogElasticExtender
public static class SerilogElasticExtender
{
public static void ErrorForElasticSearch(this Serilog.ILogger logger)
{
logger.Error("");
}
}
To Reproduce
Call _integratorLogging.Value.ErrorForElasticSearch();
Expected behavior
I expect the following string to be sent to the endpoint:
"[{"Timestamp":"2022-08-01T09:31:19.8207278Z","Level":"Error","MessageTemplate":"","RenderedMessage":""}]"
But I found this string to be sent to the endpoint, which results in an error, because this string is no valid Json.
"[{"Timestamp":"2022-08-01T09:31:19.8207278Z","Level":"Error","MessageTemplate":"","RenderedMessage":""}\r\n]"
Additional context
The Real LoggingMessage was excluded in the given code snippets because the issue happens regardless of values.
Describe the bug
Function "Error()" of Serilog.ILogger is adding the \r\n escape characters to the string.
I am currently using the following Code to send a Log Message to an HTTP endpoint.
Serilog.Sinks 2.11.0
Serilog.SInks.Http 8.0.0
Adding Http Sink to LoggerConfiguration
SerilogHttpClientFactory creates an Object of type "SerilogHttpClient"
SerilogHttpClient
SerilogElasticExtender
To Reproduce
Call _integratorLogging.Value.ErrorForElasticSearch();
Expected behavior
I expect the following string to be sent to the endpoint:
"[{"Timestamp":"2022-08-01T09:31:19.8207278Z","Level":"Error","MessageTemplate":"","RenderedMessage":""}]"
But I found this string to be sent to the endpoint, which results in an error, because this string is no valid Json.
"[{"Timestamp":"2022-08-01T09:31:19.8207278Z","Level":"Error","MessageTemplate":"","RenderedMessage":""}\r\n]"
Additional context
The Real LoggingMessage was excluded in the given code snippets because the issue happens regardless of values.