Open krishamagar opened 1 year ago
I have this path but the file is not saving in the mentioned path.
I think you need to use forward slash to save correctly
Also, once you configured this sink, date will never change. I'm assuming you want to create files on different folders based on current date.
In that case, you would like to read #30 that states it is necessary to use WriteTo.Map
I think you need to use forward slash to save correctly
I think this is correct, yes.
For me path doesn't work either. For those who have problems with saving logs somewhere deeper, set the bucketPath parameter.
From documentation:
bucketPath | Optionally add a sub-path for the bucket. Files are stored on S3 mytestbucket-aws/awsSubPath/log.txt in the example below. | bucketPath = "awsSubPath"
so, in your example:
var logger = new LoggerConfiguration().WriteTo
.AmazonS3(
"Log_",
bucketName,
Amazon.RegionEndpoint.APSouth1,
awsAccessKey,
awsSecretKey,
bucketPath: "folder1/folder2",
restrictedToMinimumLevel: LogEventLevel.Verbose,
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}",
new CultureInfo("en-US"),
levelSwitch: levelSwitch,
rollingInterval: Serilog.Sinks.AmazonS3.RollingInterval.Day,
encoding: Encoding.Unicode,
failureCallback: e => Console.WriteLine($"An error occured in my sink: {e.Message}")
)
.CreateLogger();
logger.Information(message);
result will be bucketName/folder1/folder2/Log_...
{ var logger = new LoggerConfiguration().WriteTo .AmazonS3( "folder1\folder2\" + fileName + "\" + date + "\" + "Log_", bucketName, Amazon.RegionEndpoint.APSouth1, awsAccessKey, awsSecretKey, restrictedToMinimumLevel: LogEventLevel.Verbose, outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}", new CultureInfo("en-US"), levelSwitch: levelSwitch, rollingInterval: Serilog.Sinks.AmazonS3.RollingInterval.Day, encoding: Encoding.Unicode, failureCallback: e => Console.WriteLine($"An error occured in my sink: {e.Message}") ) .CreateLogger(); logger.Information(message); }