How to output trancelog and EventLog to storage on windowsazure

Source: Internet
Author: User

 

How to output trancelog and EventLog to storage on windowsazure

 

1. modify web. config to enable a diagnostic listener.

<configuration>  <system.diagnostics>    <trace>      <listeners>        <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"          name="AzureDiagnostics">          <filter type="" />        </add>      </listeners>    </trace>  </system.diagnostics></configuration>

 

2. Start the diagnostic listener in the onstart function.

Public override bool onstart () {diagnosticmonitorconfiguration diagconfig = diagnosticmonitor. getdefaultinitialconfiguration (); // trance log diagconfig. logs. scheduledtransferloglevelfilter = loglevel. verbose; diagconfig. logs. scheduledtransferperiod = system. timespan. fromminutes (1); // EventLog diagconfig. windowseventlog. datasources. add ("system! * "); Diagconfig. windowseventlog. CES. Add (" application! * "); Diagconfig. windowseventlog. scheduledtransferloglevelfilter = loglevel. verbose; diagconfig. windowseventlog. scheduledtransferperiod = system. timespan. fromminutes (1); // Microsoft. windowsazure. plugins. diagnostics. connectionstring is required in. the storage connection string diagnosticmonitor configured in the cscfg file. start ("Microsoft. windowsazure. plugins. diagnostics. connectionstring ", diagconfig); Return base. onstart ();}

 

3. Output trancelog and EventLog in other code.

// Output a trancelog to the storage trace. writeline ("writetasklist... "); // output two eventlogs to the storage: EventLog eventapp2 = new EventLog (" application "); eventapp2.source =" azuretest app "; eventapp2.writeentry (count +" EventLog write (azuretest APP) "); EventLog eventsys2 = new EventLog (" system "); eventsys2.source =" azuretest sys "; eventsys2.writeentry (count +" EventLog write (azuretest sys )");

 

Reference: cloud diagnosis: control logging and tracking in Windows azure

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.