View Azure cloud service IIS logs

2019-07-16 03:37发布

问题:

I have created a simple MVC3 site that displays data from a table in an Azure database. I have created a cloud service to run the site in and can publish it successfully. I have also run the site successfully in the Azure emulator.

My problem is that when I select the page that displays the data there is an error as I get the default error page. I think I have the db connections set correctly but I cannot see any logs. So my questions are:

  • Where are the IIS logs? I would like to see what the error is.
  • Are there any other logs/diagnostics that I can use to see what the problem is?

Thanks.

回答1:

I suggest you use Windows Azure Diagnostics to collect your logs.

You can read all(setup and usage) about it here: http://msdn.microsoft.com/en-us/library/windowsazure/gg433048.aspx



回答2:

By default the only place where something might be logged is in the Windows Application Event Log. You'll need to Remote Desktop to the cloud service instance (Connect from the Instances page in the Azure Management Portal) and then open Event Viewer.

The IIS logs themselves should be available too although as per normal IIS logs these won't contain exception details. Use IIS Manager > Application > Logging when logged on to the instance to find the location.

As suggested by Magnus, you should use something like Windows Azure Diagnostics and/or ELMAH and/or log4net to log exception and diagnostic information to somewhere accessible for troubleshooting.