2
votes

For a web service, I have log4net configured and working fine locally but not when the webapp is deployed on Azure Webapp. The directory is created but there is nothing logged at the file..

Here is my config:

<log4net>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
  <file value="log/sms.log" />
  <appendToFile value="true" />
  <maximumFileSize value="10MB" />
  <maxSizeRollBackups value="10" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%date %level - %message%newline" />
  </layout>
</appender>
<logger name="TheLogger">
  <appender-ref ref="RollingFile" />
</logger>

Within my AssemblyInfo.cs I have:

[assembly: XmlConfigurator(Watch = true)]

At the Startup class i have :

public static ILog Logger { get; private set; }

    public void Configuration(IAppBuilder appBuilder)
    {
        Logger = LogManager.GetLogger("TheLogger");
        Logger.Info("Application start...");
    }

Clearly my configuration is being picked up because in my log file is written the hour/date format and also Application start... but not the logging information. What am i missing?

1

1 Answers

0
votes

Make sure you don't forget to add the root configuration. Are compiling for Debug and deploying in Azure in Release mode?

<log4net>
  <root>
    <level value="INFO" />
    <appender-ref ref="RollingFile" />
  </root>
  <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
   <!-- ... -->
  </appender>
</log4net>