Customize Entries

Before entries are sent, you can customize them using the CustomizeLogEntry event. This is an opportunity to modify information, provide additional context, or cancel the exception upload.

Ignore all exceptions of a particular type

In this example, we will ignore all ValidationExceptions:

LlamaLoggerClient client = new LlamaLoggerClient(apikey, version);
client.AddIgnoredExceptionType<ValidationException>();

Ignore exceptions per-occurrence

In this example, we will ignore an InvalidOperationException where the message contains the word "test":

LlamaLoggerClient client = new LlamaLoggerClient(apikey, version);
client.CustomizeLogEntry += Client_CustomizeLogEntry;

void Client_CustomizeLogEntry(object? sender, LlamaLogger.Core.CustomEventArgs.CustomizeLogEntryEventArgs e)
{
    if (e.LogEntry.Exception is InvalidOperationException ex && ex.Message.Contains("test"))
        e.Cancel = true; //This prevents the exception from being sent to Llama Logger
}

Modify Information

In this example, we are removing the occurrence of a particular password:

LlamaLoggerClient client = new LlamaLoggerClient(apikey, version);
client.CustomizeLogEntry += Client_CustomizeLogEntry;

void Client_CustomizeLogEntry(object? sender, LlamaLogger.Core.CustomEventArgs.CustomizeLogEntryEventArgs e)
{
    if (Convert.ToBoolean(e.LogEntry.ExceptionString?.Contains("Pa$$word")))
        e.LogEntry.ExceptionString = e.LogEntry.ExceptionString.Replace("Pa$$word", "***REMOVED****");
}
An error has occurred. This application may no longer respond until reloaded. Reload 🗙