title: Serilog: azure webjob logging doesn't seem to work when hosted in azure?
body: <p>I have azure webjob sdk (v3.0.3) app which has been configured to use serilog for logging.
  The log seems to work when I run the app locally in my system. Below is the configuration:</p>
  
  <pre><code>    static void Main(string[] args)
          {
              try
              {
                  var builder = new HostBuilder()
                          .ConfigureAppConfiguration(SetupConfiguration)
                          .ConfigureLogging(SetupLogging)
                          .ConfigureServices(SetupServices)
                          .ConfigureWebJobs(webJobConfiguration =&gt;
                          {
                              webJobConfiguration.AddTimers();
                              webJobConfiguration.AddAzureStorageCoreServices(); //this is to store logs in azure storage 
                          })
                          .UseSerilog()
                      .Build();
                  builder.Run();
              }
  }
  </code></pre>
  
  <p>The code for SetupConfiguration is below:</p>
  
  <pre><code>  private static void SetupConfiguration(HostBuilderContext hostingContext, IConfigurationBuilder builder)
          {
              var env = hostingContext.HostingEnvironment;
              _configuration = new ConfigurationBuilder()
                  .SetBasePath(Directory.GetCurrentDirectory())
                  .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                  .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: false, reloadOnChange: true)
                  .AddEnvironmentVariables()
                  .Build();
          }
  </code></pre>
  
  <p>The code for setting up services:</p>
  
  <pre><code>private static void SetupServices(HostBuilderContext hostingContext, IServiceCollection serviceCollection)
      {
          serviceCollection.AddSingleton&lt;IConfiguration&gt;(_configuration);
          Log.Logger = new LoggerConfiguration()
              .ReadFrom.Configuration(_configuration)
              .CreateLogger();
          _logger = serviceCollection.BuildServiceProvider().GetRequiredService&lt;ILoggerFactory&gt;().CreateLogger("test");
      }
  </code></pre>
  
  <p>The logging is setup as following:</p>
  
  <pre><code>  private static void SetupLogging(HostBuilderContext hostingContext, ILoggingBuilder loggingBuilder)
          {
              loggingBuilder.SetMinimumLevel(LogLevel.Information);
              loggingBuilder.AddConsole();
              loggingBuilder.AddDebug();
              loggingBuilder.AddSerilog(dispose: true);
          }
  </code></pre>
  
  <p>In my TimerTrigger method I'm using the logger:</p>
  
  <pre><code>[Singleton]
          public async static Task Trigger([TimerTrigger("%Job%")]TimerInfo myTimer)
          {           
            _logger.LogInformation($"From Trigger {DateTime.UtcNow.ToString()}");
  
          }
  </code></pre>
  
  <p>In appSettings.json, serilog is configured as follows:</p>
  
  <pre><code>"Serilog": {
      "MinimumLevel": "Information",
      "WriteTo": [
          {
              "Name": "RollingFile",
              "Args": {
                  "pathFormat": ".\\Log\\log-{Date}.txt",
                  "retainedFileCountLimit": 7,
                  "fileSizeLimitBytes": 5000000,
                  "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} {EventId} [{Level}] [{Properties}] {Message}{NewLine}{Exception}"
              }
          }
      ]
  }
  </code></pre>
  
  <p>the folder "Log" and the log files get created when i run the app locally. But when I publish the webjob, the "Log" folder or the log file is not created in the "app_data" folder of webjob. Can anyone help me figureout how to configure serilog to make it work with webjobs?</p>
  
  <p>Following are the nuget packages used:
  <a href="https://i.stack.imgur.com/URRAU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/URRAU.png" alt="enter image description here"></a></p>