//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