Created
December 25, 2016 23:04
-
-
Save MoaidHathot/bd34e1095908246d299abfbb135e0997 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For testing purposes...throws exception once per <ThrowExceptionForCount> | |
public class ExceptionThrowerAppender : ConsoleAppender | |
{ | |
public int ThrowExceptionForCount { get; set; } = 1; | |
private int _count; | |
public ExceptionThrowerAppender() | |
{ | |
ErrorHandler = new PropogateErrorHandler(); | |
} | |
protected override void Append(LoggingEvent loggingEvent) | |
{ | |
if (0 == System.Threading.Interlocked.Increment(ref _count) % ThrowExceptionForCount) | |
{ | |
throw new Exception($"Interval {ThrowExceptionForCount} is reached with counter {_count}"); | |
} | |
base.Append(loggingEvent); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment