1

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

C. Augusto Proiete
  • 24,684
  • 2
  • 63
  • 91
advapi
  • 3,661
  • 4
  • 38
  • 73
  • Yes, you could use a destructurer to only include the properties you want. You can even [use attributes](https://nblumhardt.com/2014/07/using-attributes-to-control-destructuring-in-serilog/). Did you try it? What was the result? Did you [enable self logging](https://github.com/serilog/serilog/wiki/Debugging-and-Diagnostics#selflog) as described in their documentation? – mason May 29 '20 at 19:28

1 Answers1

1

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.

liammclennan
  • 5,295
  • 3
  • 34
  • 30