{"id":14867,"date":"2013-06-17T11:43:11","date_gmt":"2013-06-17T11:43:11","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/webdev\/2013\/06\/17\/view-persisted-logs-in-azure-storage-in-visual-studio-2012\/"},"modified":"2024-01-18T08:24:38","modified_gmt":"2024-01-18T16:24:38","slug":"view-persisted-logs-in-azure-storage-in-visual-studio-2012-2","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/view-persisted-logs-in-azure-storage-in-visual-studio-2012-2\/","title":{"rendered":"View Persisted Logs in Azure Storage in Visual Studio 2012"},"content":{"rendered":"<p><font size=\"2\">In ScottGu\u2019s Blog \u201c<\/font><a href=\"http:\/\/weblogs.asp.net\/scottgu\/archive\/2013\/04\/30\/announcing-the-release-of-windows-azure-sdk-2-0-for-net.aspx\" target=\"_blank\" rel=\"noopener\"><font color=\"#0000ff\" size=\"2\">Announcing the release of Windows Azure SDK 2.0 for .NET<\/font><\/a><font size=\"2\">\u201d, among all other new features, you learn how to stream your Windows Azure Web Site\u2019s application logs into Visual Studio. It might be also useful if you persist those same logs in Azure Table Storage and view them in Visual Studio for certain time intervals. This blog will describe the steps how to achieve that.<\/font><\/p>\n<p><font size=\"2\">You need to install Windows Azure SDK 2.0 for .NET from <a href=\"http:\/\/www.windowsazure.com\/en-us\/develop\/net\/\" target=\"_blank\" rel=\"noopener\"><font color=\"#0000ff\">Windows Azure .NET Developer Center<\/font><\/a> in order to use this feature.<\/font><\/p>\n<p> <font size=\"2\"><\/font>  <\/p>\n<h2><font size=\"2\">Add Tracing To Your Application<\/font><\/h2>\n<p> <font size=\"2\"><\/font>  <\/p>\n<p><font size=\"2\">Add some tracing in a WebForm application with Systyem.Diagnostics.Trace. To test, I usually add some traces inside the Page_Load method as shown below.<\/font><\/p>\n<p> <font size=\"2\"><\/font>  <\/p>\n<p class=\"csharpcode\">\n<p> <font size=\"2\"><\/font>  <\/p>\n<pre><font size=\"2\"><span class=\"lnum\">   1:  <\/span>    <span class=\"kwrd\">public<\/span> <span class=\"kwrd\">partial<\/span> <span class=\"kwrd\">class<\/span> _Default : Page<\/font><\/pre>\n<p><font size=\"2\"><\/font><\/p>\n<pre><font size=\"2\"><span class=\"lnum\">   2:  <\/span>    {<\/font><\/pre>\n<p><font size=\"2\"><\/font><\/p>\n<pre><font size=\"2\"><span class=\"lnum\">   3:  <\/span>        <span class=\"kwrd\">protected<\/span> <span class=\"kwrd\">void<\/span> Page_Load(<span class=\"kwrd\">object<\/span> sender, EventArgs e)<\/font><\/pre>\n<p><font size=\"2\"><\/font><\/p>\n<pre><font size=\"2\"><span class=\"lnum\">   4:  <\/span>        {<\/font><\/pre>\n<p><font size=\"2\"><\/font><\/p>\n<pre><font size=\"2\"><span class=\"lnum\">   5:  <\/span>            System.Diagnostics.Trace.TraceError(<span class=\"str\">&quot;Application Error.&quot;<\/span>);<\/font><\/pre>\n<p><font size=\"2\"><\/font><\/p>\n<pre><font size=\"2\"><span class=\"lnum\">   6:  <\/span>            System.Diagnostics.Trace.TraceWarning(<span class=\"str\">&quot;Application Warning.&quot;<\/span>);<\/font><\/pre>\n<p><font size=\"2\"><\/font><\/p>\n<pre><font size=\"2\"><span class=\"lnum\">   7:  <\/span>            System.Diagnostics.Trace.TraceInformation(<span class=\"str\">&quot;Application Information.&quot;<\/span>);<\/font><\/pre>\n<p><font size=\"2\"><\/font><\/p>\n<pre><font size=\"2\"><span class=\"lnum\">   8:  <\/span>            System.Diagnostics.Trace.WriteLine(<span class=\"str\">&quot;Application WriteLine.&quot;<\/span>);<\/font><\/pre>\n<p><font size=\"2\"><\/font><\/p>\n<pre><font size=\"2\"><span class=\"lnum\">   9:  <\/span>        }<\/font><\/pre>\n<p><font size=\"2\"><\/font><\/p>\n<pre><font size=\"2\"><span class=\"lnum\">  10:  <\/span>    }<\/font><\/pre>\n<p><font size=\"2\"><\/font><\/p>\n<p><font size=\"2\">Publish the project to Azure from VS 2012.<\/font><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<h2><font size=\"2\">Store Application Logs in an Azure Table Storage<\/font><\/h2>\n<p><font size=\"2\"><\/font><\/p>\n<p><font size=\"2\">&#8211; At the Azure Portal, create a storage to store our application logs.<\/font><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/06\/6281.image_thumb_39DC4B98.png\"><img decoding=\"async\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/06\/6281.image_thumb_39DC4B98.png\" width=\"644\" height=\"182\" \/><\/a><\/font><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p>&#160;<\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p><font size=\"2\">&#8211; You need to associate your web site with this storage by clicking on the \u201cmanage connection\u201d under the Configure tab of your Azure site.<\/font><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/06\/4150.image_thumb_12A20263.png\"><img decoding=\"async\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/06\/4150.image_thumb_12A20263.png\" width=\"472\" height=\"189\" \/><\/a><\/font><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p>&#160;<\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p><font size=\"2\">&#8211; Select the storage you created above in the pop-up dialog.<\/font><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/06\/2577.image_thumb_00593BA1.png\"><img decoding=\"async\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/06\/2577.image_thumb_00593BA1.png\" width=\"402\" height=\"276\" \/><\/a><\/font><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p>&#160;<\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p><font size=\"2\">&#8211; This setting will show up under the Connection strings section of the site after the steps above.<\/font><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/06\/4666.image_thumb_64487CB5.png\"><font size=\"2\"><img decoding=\"async\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/06\/4666.image_thumb_64487CB5.png\" width=\"640\" height=\"103\" \/><\/font><\/a><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p>&#160;<\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p><font size=\"2\">Alternatively, you can set this connection string \u201cCLOUD_STORAGE_ACCOUNT\u201d manually within VS if you know the storage account key<\/font><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/06\/4064.image_thumb_2412633B.png\"><font size=\"2\"><img decoding=\"async\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/06\/4064.image_thumb_2412633B.png\" width=\"644\" height=\"166\" \/><\/font><\/a><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p><font size=\"2\">&#8211; You can obtain the storage account\u2019s key from the \u201cModify Account\u201d dialog of the storage listed under \u201cWindows Azure Storage\u201d node in Server Explorer in Visual Studio.<\/font><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/06\/6153.image_thumb_78CDCC33.png\"><font size=\"2\"><img decoding=\"async\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/06\/6153.image_thumb_78CDCC33.png\" width=\"644\" height=\"338\" \/><\/font><\/a><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p><font size=\"2\">Now you\u2019re ready to see how things will work together.<\/font><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p><font size=\"2\">First, we need to generate some application logs so we can view them later. Using the Azure Web Site with System.Diagnostics traces that we added at the beginning of this blog, each time we view\/\/refresh the Default page in a browser, log will be generated and persisted in the Azure Table storage associated with the site.<\/font><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<h2><font size=\"2\">View the Most Recent Application Logs in Azure Table<\/font><\/h2>\n<p><font size=\"2\"><\/font><\/p>\n<p><font size=\"2\">&#8211; Switch to the Logs tab of the site\u2019s Settings window.<\/font><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/06\/4503.image_thumb_5F65C8F9.png\"><img decoding=\"async\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/06\/4503.image_thumb_5F65C8F9.png\" width=\"918\" height=\"230\" \/><\/a><\/font><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p><font size=\"2\">&#8211; The first time you open this Logs tab, you will see the spinning wheel indicating that it\u2019s trying to retrieve the application logs in the Azure storage of the site. When the retrieval is complete, you will see the logs displayed in the table .<\/font><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/06\/7230.image_thumb_43550A0E.png\"><font size=\"2\"><img decoding=\"async\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/06\/7230.image_thumb_43550A0E.png\" width=\"644\" height=\"177\" \/><\/font><\/a><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p><font size=\"2\">&#8211; You can change the time interval when the logs being stored in the Azure storage by change the dropdown selection<\/font><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/06\/6253.image_thumb_6A23204E.png\"><font size=\"2\"><img decoding=\"async\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/06\/6253.image_thumb_6A23204E.png\" width=\"644\" height=\"144\" \/><\/font><\/a><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p><font size=\"2\">Also, if you want to view all the logs in the storage, click on the link on the upper right \u201cView all application logs\u201d, shown in the above picture. This will take you to the WAWSAppLogTable tab which lists all the loggings.<\/font><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/06\/3513.image_thumb_6303E3D6.png\"><font size=\"2\"><img decoding=\"async\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/06\/3513.image_thumb_6303E3D6.png\" width=\"644\" height=\"228\" \/><\/font><\/a><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p>&#160;<\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p><font size=\"2\">Note that by default, it will log only Application Errors traces of your site. To change the logging level, you need to go to the Configure tab of your site\u2019s Portal UI<\/font><\/p>\n<p><font size=\"2\"><\/font><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/06\/2364.image_thumb_69B6ED59.png\"><img decoding=\"async\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/06\/2364.image_thumb_69B6ED59.png\" width=\"458\" height=\"198\" \/><\/a>&#160;<\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In ScottGu\u2019s Blog \u201cAnnouncing the release of Windows Azure SDK 2.0 for .NET\u201d, among all other new features, you learn how to stream your Windows Azure Web Site\u2019s application logs into Visual Studio. It might be also useful if you persist those same logs in Azure Table Storage and view them in Visual Studio for [&hellip;]<\/p>\n","protected":false},"author":423,"featured_media":58792,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[197],"tags":[],"class_list":["post-14867","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aspnet"],"acf":[],"blog_post_summary":"<p>In ScottGu\u2019s Blog \u201cAnnouncing the release of Windows Azure SDK 2.0 for .NET\u201d, among all other new features, you learn how to stream your Windows Azure Web Site\u2019s application logs into Visual Studio. It might be also useful if you persist those same logs in Azure Table Storage and view them in Visual Studio for [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/14867","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/423"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=14867"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/14867\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/58792"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=14867"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=14867"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=14867"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}