Amazon S3 sink in serilog is not working. How to use s3 Sink with serilog?

446 views Asked by At
    public class program
{
    public static void Main(String args[])
    {
        var levelSwitch = new LoggingLevelSwitch();
        levelSwitch.MinimumLevel = LogEventLevel.Information;
        try
        {
            var logger = new LoggerConfiguration().WriteTo
            .AmazonS3(
              "log.txt",
              "xxxxxxx",  //bucketName
              Amazon.RegionEndpoint.EUWest1,
              "xxxx",  //accessKey
              "xxxx",  //secretKey
              restrictedToMinimumLevel: LogEventLevel.Information,
              outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}",
              new CultureInfo("de-DE"),
              levelSwitch: levelSwitch,
              rollingInterval: RollingInterval.Minute,
              encoding: Encoding.Unicode
              )
          .CreateLogger();
            logger.Debug("Hello world Debug mode on");
            logger.Information("Hello world Debug mode on");
            logger.Error("Hello world Debug mode on");

        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
    }
}

and if I remove output template and culture then I face the ambiguity error. How can I use this amazon s3 sink correctly ?. and I am not getting any error in the catch block and nothing happen in the s3 bucket there was no file is making

1

There are 1 answers

1
utkarsh singh On

this is working after flush or dispose the logger. is there any workaround it can automatically saves the buffer.