Skip to content

Instantly share code, notes, and snippets.

@christiansparre
Last active August 27, 2017 14:03
Show Gist options
  • Select an option

  • Save christiansparre/0d1a322dce7fefb39590b73fba23b6f7 to your computer and use it in GitHub Desktop.

Select an option

Save christiansparre/0d1a322dce7fefb39590b73fba23b6f7 to your computer and use it in GitHub Desktop.
Azure Queue Storage Serilog Sink
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