1 year ago

#132738

test-img

user15716642

In .NET Core is there a specific way to prevent this file content log from being written as-is?

I'm using a JSON log sink which destructures complex properties. For some reason, Microsoft has this log built-in when you return a file content result from your controller action:

Executing {FileResultType}, sending file with download name '{FileDownloadName}' ...

Tat FileResultType has a nested property which includes the actual byte array, so my log space will be blown out if I don't get rid of this.

json log snippet

I know how to filter out a specific logger by name, so I can do that.. But I really just don't want this specific object to be logged out. I still find the rest of the message very helpful. I'm not sure if there's a flag I can toggle to bypass this or what since Microsoft is definitely aware that many people are using log sinks which serialize complex objects instead of just calling .ToString(), but I haven't found anything yet. I'm using NLog so I'm sure I can get creative there with some if conditions, but it'd be pretty inefficient because that check would have to run on every single log attempt.

c#

logging

nlog

filecontentresult

0 Answers

Your Answer

Accepted video resources