Desperately seeking a solution to get log4net working in a Azure Worker Role. Slowly driving me c-razy.
I've followed the steps outlined on this blog http://blog.tylerdoerksen.com/2012/04/17/logging-in-azure-part-2table-storage (thanks) which seem to make sense and the log4net logging works like an dream in the following conditions:
- Running the Worker Role in the emulator locally and persisting the logs to local Storage
- Running the Worker Role in the emulator locally and persisting the logs to remote staging Azure Table Storage
When I deploy the Worker Role Service to Azure it logs nothing in the LogEntities table. It's this bit, this bit that is incredibly frustrating.
I've turned on log4net debugging in the Worker Role app.config and I see the following trace in the WADLogsTable
log4net: Finalizing appender named [TableStorageAppender].
And that's it. No other log4net debug info that I'd normally expect to see since adding the
<appSettings>
<add key="log4net.Internal.Debug" value="true"/>
</appSettings>
to my Worker Role app.config.
I'm configuring log4net in the Worker Role overridden Run method:
public override void Run()
{
try
{
XmlConfigurator.Configure();
ILog Logger = LogManager.GetLogger(GetType());
Trace.WriteLine("Trace: CheckInService.Run()");
Logger.Info("log4net: CheckInService.Run()");
//open the Service and do some other stuff etc
while (true)
{
Thread.Sleep(1800000);
}
catch (Exception ex)
{
Trace.TraceError("There was a problem opening the CheckInService");
}
}
This is my full app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" name="log4net" />
</configSections>
<appSettings>
<add key="log4net.Internal.Debug" value="true"/>
</appSettings>
<log4net>
<appender type="Cloud.Services.Logging.TableStorageAppender, Cloud.Services.Logging" name="TableStorageAppender">
</appender>
<root>
<level value="All" />
<appender-ref ref="TableStorageAppender" />
</root>
</log4net>
<system.diagnostics>
<trace autoflush="true">
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>
</configuration>
The logging appender (TableStorageAppender) implementation is in it's own Assembly (Cloud.Services.Logging) but I'm assuming that wouldn't make any difference?
Anyone got any ideas?