{"id":5442,"date":"2017-10-03T19:11:03","date_gmt":"2017-10-03T19:11:03","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=5442"},"modified":"2017-10-03T19:19:58","modified_gmt":"2017-10-03T19:19:58","slug":"combing-serilog-and-table-storage","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/combing-serilog-and-table-storage\/","title":{"rendered":"Combining Serilog and Table Storage"},"content":{"rendered":"<p>As I&#8217;ve written posts on Serilog and Azure Storage recently, I thought I&#8217;d try to combine them both and use Azure table storage for the logging sink. Thankfully, I didn&#8217;t need to code anything myself, as this type of sink has already been written, see the <a href=\"https:\/\/github.com\/serilog\/serilog-sinks-azuretablestorage\" rel=\"noopener\" target=\"_blank\">AzureTableStorage<\/a> sink.<\/p>\n<p>If we take the basic code from <a href=\"http:\/\/putridparrot.com\/blog\/serilog-revisited-now-version-2-5\/\" rel=\"noopener\" target=\"_blank\">Serilog revisited (now version 2.5)<\/a> and <a href=\"http:\/\/putridparrot.com\/blog\/azure-table-storage\/\" rel=\"noopener\" target=\"_blank\">Azure Table Storage<\/a> and include the glue of <a href=\"https:\/\/github.com\/serilog\/serilog-sinks-azuretablestorage\" rel=\"noopener\" target=\"_blank\">AzureTableStorage<\/a>. We get the following<\/p>\n<ul>\n<li>Add NuGet Package Serilog.Sinks.AzureTableStorage<\/li>\n<\/ul>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nvar storageAccount = CloudStorageAccount.Parse(\r\n   CloudConfigurationManager.GetSetting(\r\n   &quot;StorageConnectionString&quot;));\r\n\r\nLog.Logger = new LoggerConfiguration()\r\n   .WriteTo.AzureTableStorage(storageAccount, storageTableName: &quot;MyApp&quot;)\r\n   .CreateLogger();\r\n\r\nLog.Logger.Information(&quot;Application Started&quot;);\r\n\r\nfor (var i = 0; i &lt; 10; i++)\r\n{\r\n   Log.Logger.Information(&quot;Iteration {I}&quot;, i);\r\n}\r\n\r\nLog.Logger.Information(&quot;Exiting Application&quot;);\r\n<\/pre>\n<p>Without the storageTableName we&#8217;ll have the table LogEventEntity as the default table name. That&#8217;s all there is to it, now we&#8217;re sending our log entries into the cloud.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As I&#8217;ve written posts on Serilog and Azure Storage recently, I thought I&#8217;d try to combine them both and use Azure table storage for the logging sink. Thankfully, I didn&#8217;t need to code anything myself, as this type of sink has already been written, see the AzureTableStorage sink. If we take the basic code from [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[96,126,125],"tags":[],"class_list":["post-5442","post","type-post","status-publish","format-standard","hentry","category-azure-2","category-logging","category-serilog"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/5442","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=5442"}],"version-history":[{"count":3,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/5442\/revisions"}],"predecessor-version":[{"id":5453,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/5442\/revisions\/5453"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=5442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=5442"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=5442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}