How can we log on Azure withe the granularity & control equivalent to log4net? We use log4net in our web apps we run on IIS and that works very well for us. Is that the
The best way to log data for Azure VMs or Cloud Services is to use Log4Net to log to disk as well as log information from all your instances to an Azure storage account. The advantage is that you will get a more robust solution. If for some reason Azure Diagnostics breaks during a live site, you can still remote into any of the instances and try to diagnose the issue. For other services such as web apps, where you can't remote into the instances, it is sufficient to log information to Azure Storage accounts.
It will take you half a day or a day to setup and test but I hope that answers your question.
I think you should be careful when storing the log file locally in Azure as this is not garanteed to stick around. The VM used to store the website can be reimaged and the logs will be lost.
A better solution is to use Azure diagnostics combined with log4net (would work the same for other logging mechanisms such as NLog). Process is sumarrized here:
Set up local storage as a place on the role instance (virtual machine) where log files are written.
Add a element to the diagnostics.wadcfg file to instruct Azure diagnostics to create and use a container in blob storage.
Add a element within to instruct Azure diagnostics to monitor the logging folder within the LogStorage local resource location.
This way the locally stored logs will be copied to the blob storage.
Full story here: http://justazure.com/microsoft-azure-diagnostics-part-1-introduction/
This is pretty straight forward. I use the following log4net
configuration to dump a log file in the web application root folder (easily changed to a sub-folder):
<log4net>
<root>
<level value="DEBUG" />
<appender-ref ref="LogFileAppender" />
</root>
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender" >
<param name="File" value="my_web.log" />
<param name="AppendToFile" value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="10MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%date{yyyy-dd-MM HH:mm:ss.fff} [%thread] %-5level %logger.%method [%property{NDC}] - %message%newline" />
</layout>
</appender>
</log4net>
I then inspect the log file when needed directly from Visual Studio (double clicking the file downloads it) Server Explorer: