How to capture only app domain log messages

516 views
Skip to first unread message

Justin Cersey

unread,
Mar 9, 2016, 5:03:09 PM3/9/16
to Serilog
Hi. I have successfully added Serilog to my ASP.NET Core project and am using the RollingFile sink. This captures all messages from my application as well as messages from the .NET framework. I have not been able to figure out how to exclude messages that are not from my own application code. I am aware of Filter.ByIncludingOnly and Filter.ByExcluding, but I am not sure how this can be used to accomplish my scenario or if there is another way to go about it. What is the proper way to configure Serilog to only capture log messages from my own application code? Thanks.

nblum...@nblumhardt.com

unread,
Mar 9, 2016, 5:07:59 PM3/9/16
to Serilog
Hello Justin,

.Filter.ByExcluding(Matching.FromSource("Microsoft"))

should cover it.

The other option, depending on your preferences, is to use Serilog directly from your code, and only hook up Serilog.Extensions.Logging when/if you need events from the framework.

Let me know how you go! :-)

Cheers,
Nick

Justin Cersey

unread,
Mar 9, 2016, 5:24:49 PM3/9/16
to Serilog
The filter worked perfectly. I just had to add "using Serilog.Filters" Thanks Nick!
Reply all
Reply to author
Forward
0 new messages