Last active
August 27, 2017 14:03
-
-
Save christiansparre/0d1a322dce7fefb39590b73fba23b6f7 to your computer and use it in GitHub Desktop.
Azure Queue Storage Serilog Sink
This file contains hidden or 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
| public class AzureQueueStorageSink : ILogEventSink | |
| { | |
| CloudQueue _queue; | |
| ITextFormatter _formatter; | |
| public AzureQueueStorageSink(CloudQueue queue, ITextFormatter formatter) | |
| { | |
| _queue = queue; | |
| _formatter = formatter; | |
| } | |
| public void Emit(LogEvent logEvent) | |
| { | |
| using (var writer = new StringWriter()) | |
| { | |
| _formatter.Format(logEvent, writer); | |
| var message = new CloudQueueMessage(writer.ToString()); | |
| _queue.AddMessage(message); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment