title: Serilogs not working in linux server in aspnet core 2.1
body: <p>I'm creating dotnet core 2.1 project.I used serilogs.In my windows machine it's working fine.But after hosted it,serilogs not working.Not creating logs folder and log file.I hosted it in ubuntu 18.04 version server.
  I tried it by creating logs folder manually and gave it to read write permissions</p>
  
  <pre><code>   sudo chmod 775 /var/app/logs
     sudo chown www-data /var/app/logs
  </code></pre>
  
  <p>here is the code in program class</p>
  
  <pre><code>public class Program
  {
      public static void Main(string[] args)
      {
          Log.Logger = new LoggerConfiguration()
              .MinimumLevel.Verbose()
              .MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
              .MinimumLevel.Override("System", LogEventLevel.Warning)
              .MinimumLevel.Override("Microsoft.AspNetCore.Authentication", LogEventLevel.Information)
              .Enrich.FromLogContext()
              .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Literate)
              .WriteTo.RollingFile(@"logs\log-{Date}.log", fileSizeLimitBytes: null, retainedFileCountLimit: null)
              .CreateLogger();
          CreateWebHostBuilder(args).Build().Run();
      }
  
      public static IWebHostBuilder CreateWebHostBuilder(string[] args) =&gt;
          WebHost.CreateDefaultBuilder(args)
          .ConfigureLogging(builder =&gt;
                   {
                       builder.SetMinimumLevel(LogLevel.Warning);
                       builder.AddFilter("ApiServer", LogLevel.Debug);
                       builder.AddSerilog();
                   })
          .UseContentRoot(Directory.GetCurrentDirectory())
          .UseStartup&lt;Startup&gt;();
  }
  </code></pre>
  
  <p>here is my startup class code</p>
  
  <pre><code> public class Startup
  {
      public Startup(IConfiguration configuration)
      {
          Configuration = configuration;
      }
  
      public IConfiguration Configuration { get; }
  
      // This method gets called by the runtime. Use this method to add services to the container.
      public void ConfigureServices(IServiceCollection services)
      {
          services.AddDbContext&lt;DataContext&gt;(s =&gt; s.UseMySql(Configuration.GetConnectionString("DefaultConnection"))
          .ConfigureWarnings(warnings =&gt; warnings.Ignore(CoreEventId.IncludeIgnoredWarning)));
          services.AddMvc()
                      .SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
                      .AddJsonOptions(opt =&gt;
                      {
                          opt.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
                      });
         services.AddCors();
          services.AddAutoMapper();
          services.AddTransient&lt;Seed&gt;();
          services.AddScoped&lt;IAuthRepository, AuthRepository&gt;();
          services.AddScoped&lt;IDatingRepository, DatingRepository&gt;();
          services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
          .AddJwtBearer(options =&gt;
          {
              options.TokenValidationParameters = new TokenValidationParameters
              {
                  ValidateIssuerSigningKey = true,
                  IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII
                    .GetBytes(Configuration.GetSection("AppSettings:Token").Value)),
                  ValidateIssuer = false,
                  ValidateAudience = false
              };
          });
          services.AddScoped&lt;LogUserActivity&gt;();
  
  
  
          IdentityBuilder builder = services.AddIdentityCore&lt;User&gt;(opt =&gt;
          {
              opt.Password.RequireDigit = false;
              opt.Password.RequiredLength = 4;
              opt.Password.RequireNonAlphanumeric = false;
              opt.Password.RequireUppercase = false;
  
          });
  
          builder = new IdentityBuilder(builder.UserType, typeof(Role), builder.Services);
          builder.AddEntityFrameworkStores&lt;DataContext&gt;();
          builder.AddRoleValidator&lt;RoleValidator&lt;Role&gt;&gt;();
          builder.AddRoleManager&lt;RoleManager&lt;Role&gt;&gt;();
          builder.AddSignInManager&lt;SignInManager&lt;User&gt;&gt;();
  
  
  
          // services.AddAuthorization(options =&gt; {
          //     options.AddPolicy("RequireAdminRole", policy =&gt; policy.RequireRole("Admin"));
          //     options.AddPolicy("SuperAdminPhotoRole", policy =&gt; policy.RequireRole("SuperAdmin"));
          // });
  
  
          // services.AddCors();
  
  
      }
  
      // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
      public void Configure(IApplicationBuilder app, IHostingEnvironment env, Seed seeder, ILoggerFactory loggerFactory)
      {
          loggerFactory.AddConsole(Configuration.GetSection("Logging"))
              .AddDebug();
  
          if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
          }
          else
          {
  
              app.UseExceptionHandler(builder =&gt;
              {
                  builder.Run(async context =&gt;
                  {
                      context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
  
                      var error = context.Features.Get&lt;IExceptionHandlerFeature&gt;();
                      if (error != null)
                      {
                          context.Response.AddApplicationError(error.Error.Message);
                          await context.Response.WriteAsync(error.Error.Message);
                      }
                  });
              });
  
              // app.UseHsts();
          }
  
          // app.UseHttpsRedirection();
          seeder.SeedUsers();
          //  app.UseCors(x =&gt; x.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin().AllowCredentials());
          app.UseCors(x =&gt; x.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
          app.UseAuthentication();
          app.UseDefaultFiles();
          app.UseStaticFiles();
          app.UseMvc(routes =&gt;
          {
              routes.MapSpaFallbackRoute(
                  name: "spa-fallback",
                  defaults: new { controller = "Fallback", action = "Index" }
              );
          });
      }
  }
  </code></pre>
  
  <p>here is the way I used logs</p>
  
  <pre><code>public class PhotosController : ControllerBase
  {
      private readonly ILogger&lt;PhotosController&gt; _logger;
  
      public PhotosController(ILogger&lt;PhotosController&gt; logger
      )
      {
          _logger = logger;
  
      }
  
       [HttpPost("{id}/setMain")]
        public async Task&lt;IActionResult&gt; SetMainPhoto(Guid id)
      {
          try
          {
               _logger.LogDebug("Starting to change main photo");  
          }
          catch(Exception e) {
       _logger.LogError("An error occurs while changing photo");
        }}}
  </code></pre>
  
  <p>Please help me to solve this problem.this is working fine in windows machine.Only this happened after hosting</p>