Custom Filters
Implement ILogFilter:
using Logix.Abstractions;
public class KeywordFilter : ILogFilter
{
private readonly string[] _keywords;
public KeywordFilter(params string[] keywords) => _keywords = keywords;
public bool ShouldLog(LogMessage msg)
{
if (msg.Message == null) return true;
foreach (var kw in _keywords)
if (msg.Message.ToString().Contains(kw, StringComparison.OrdinalIgnoreCase))
return true;
return false;
}
}
ShouldLog receives the full LogMessage with Created, Level, Message, File, Line, and StackTrace.
Log.Container.AddFilter(new KeywordFilter("urgent", "critical"));