Object logging do not works after following structured logging
tomasr78 opened this issue · 2 comments
tomasr78 commented
I have a logging error code
Logger.Main.LogError($"Api status={statusCode} message={e.Message} uri={uri} {requestId}", new
{
e.HttpStatusCode,
e.StatusCode,
e.Message,
e.InvalidParameters,
e.Details
});
After refactoring like structured logging suggest the ode looks like below. Unfortunately, the last parameter anonymous object is not logged anymore. Is this the problem with my Logging implementation or I just missing something?
Logger.Main.LogError("Api status={StatusCode} message={Message} uri={Uri} {RequestId}", statusCode, e.Message, uri, requestId, new
{
e.HttpStatusCode,
e.StatusCode,
e.Message,
e.InvalidParameters,
e.Details
});
olsh commented
Hi @tomasr78
Could you please specify which logging library you are using?
I belive you need to add an additional parameter to the logger template and destructure it. Something like this:
Logger.Main.LogError("Api status={StatusCode} message={Message} uri={Uri} {RequestId} {@ResponseObject}", statusCode, e.Message, uri, requestId, new
{
e.HttpStatusCode,
e.StatusCode,
e.Message,
e.InvalidParameters,
e.Details
});
olsh commented
Closed due to inactivity