Serilog event not saved

130 views Asked by At

I'm trying to log to file / seq an event that's an API response from a web service. I know it's not best practice, but under some circumstances, I need to do so. The JSON saved on disk is around 400Kb.to be honest, I could exclude 2 part of it (that are images returned as base64), I think I should use a destructured logger, is it right? I've tried increasing the Seq limit to 1mb but the content is not saved even to log file so I think that's not the problem...I use Microsoft Logging (ILogger interface) with Serilog.AspnetCore

Is there a way I can handle such a scenario? Thanks in advance

1

There are 1 answers

0
liammclennan On

You can log a serialized value by using the @ format option on the property name. For example,

Log.Information("Created {@User} on {Created}", exampleUser, DateTime.Now);

As you've noted it tends to be a bad idea unless you are certain that the value being serialized will always be small and simple.