HaemmerElectronics.SeppPenner.Serilog.Sinks.AmazonS3 1.0.0

Serilog.Sinks.AmazonS3 is a library to save logging information from https://github.com/serilog/serilog to https://aws.amazon.com/s3/.
The idea there was to upload log files to https://aws.amazon.com/s3/ to later evaluate them with https://aws.amazon.com/emr/ services.
The assembly was written and tested in .Net Framework 4.8 and .Net Standard 2.0.
This project makes use of the https://github.com/serilog/serilog-sinks-file's code in a major part,
so thanks to all the https://github.com/serilog/serilog-sinks-file/graphs/contributors of this project :thumbsup:.

There is a newer version of this package available.
See the version list below for details.
Install-Package HaemmerElectronics.SeppPenner.Serilog.Sinks.AmazonS3 -Version 1.0.0
dotnet add package HaemmerElectronics.SeppPenner.Serilog.Sinks.AmazonS3 --version 1.0.0
<PackageReference Include="HaemmerElectronics.SeppPenner.Serilog.Sinks.AmazonS3" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add HaemmerElectronics.SeppPenner.Serilog.Sinks.AmazonS3 --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Serilog.Sinks.AmazonS3

Serilog.Sinks.AmazonS3 is a library to save logging information from Serilog to Amazon S3.
The idea there was to upload log files to Amazon S3 to later evaluate them with Amazon EMR services.
The assembly was written and tested in .Net Framework 4.8 and .Net Standard 2.0.
This project makes use of the Serilog.Sinks.File's code in a major part,
so thanks to all the contributors of this project :thumbsup:.

Build status
GitHub issues
GitHub forks
GitHub stars
GitHub license
Nuget
NuGet Downloads
Known Vulnerabilities

Available for

  • NetFramework 4.5
  • NetFramework 4.6
  • NetFramework 4.6.2
  • NetFramework 4.7
  • NetFramework 4.7.2
  • NetFramework 4.8
  • NetStandard 2.0

Basic usage:

var logger = new LoggerConfiguration().WriteTo
    .AmazonS3(
        "log.txt",
        "mytestbucket-aws",
        Amazon.RegionEndpoint.EUWest2,
        "ABCDEFGHIJKLMNOP",
        "c3fghsrgwegfn://asdfsdfsdgfsdg",
        fileSizeLimitBytes: 200,
        rollingInterval: RollingInterval.Minute)
    .CreateLogger();

    for (var x = 0; x < 200; x++)
    {
        var ex = new Exception("Test");
        logger.Error(ex.ToString());
    }

The project can be found on nuget.

Configuration options:

|Parameter|Meaning|Example|Default value|
|-|-|-|-|
|path|The main log file name used.|&quot;log.txt&quot;|None, is mandatory.|
|bucketName|The name of the Amazon S3 bucket to use. Check: https://docs.aws.amazon.com/general/latest/gr/rande.html.|&quot;mytestbucket-aws&quot;|None, is mandatory.|
|endpoint|The Amazon S3 endpoint location.|RegionEndpoint.EUWest2|None, is mandatory.|
|awsAccessKeyId|The Amazon S3 access key id.|ABCDEFGHIJKLMNOP|None, is mandatory.|
|awsSecretAccessKey|The Amazon S3 secret access key.|c3fghsrgwegfn://asdfsdfsdgfsdg|None, is mandatory.|
|restrictedToMinimumLevel|The minimum level for events passed through the sink. Ignored when levelSwitch is specified. Check: https://github.com/serilog/serilog/blob/dev/src/Serilog/Events/LogEventLevel.cs.|LogEventLevel.Information|LogEventLevel.Verbose|
|outputTemplate|A message template describing the format used to write to the sink.|&quot;{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}&quot;|&quot;{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}&quot;|
|formatProvider|The IFormatProvider to use. Supplies culture-specific formatting information. Check: https://docs.microsoft.com/en-us/dotnet/api/system.iformatprovider?view=netframework-4.8.|new CultureInfo(&quot;de-DE&quot;)|null|
|fileSizeLimitBytes|The number of bytes in a file. The sink rolls to a new file after the limit is reached.|200|1L * 1024 * 1024 * 1024|
|levelSwitch|A switch allowing the pass-through minimum level to be changed at runtime. Check: https://nblumhardt.com/2014/10/dynamically-changing-the-serilog-level/.|var levelSwitch = new LoggingLevelSwitch(); levelSwitch.MinimumLevel = LogEventLevel.Warning;|null|
|buffered|Indicates if flushing to the output file can be buffered or not.|buffered: true|false|
|rollingInterval|The interval at which logging will roll over to a new file. Check: https://github.com/serilog/serilog-sinks-file/blob/dev/src/Serilog.Sinks.File/RollingInterval.cs.|rollingInterval: RollingInterval.Minute|RollingInterval.Day|
|retainedFileCountLimit|The maximum number of log files that will be retained, including the current log file. For unlimited retention, pass null.|10|31|
|encoding|Character encoding used to write the text file. Check: https://docs.microsoft.com/de-de/dotnet/api/system.text.encoding?view=netframework-4.8.|encoding: Encoding.Unicode|null meaning Encoding.UTF8|
|hooks|Optionally enables hooking into log file lifecycle events. Check: https://github.com/serilog/serilog-sinks-file/blob/dev/src/Serilog.Sinks.File/Sinks/File/FileLifecycleHooks.cs and https://github.com/cocowalla/serilog-sinks-file-header/blob/master/src/Serilog.Sinks.File.Header/HeaderWriter.cs.|hooks: new HeaderWriter(&quot;Timestamp,Level,Message&quot;)|null|

Full example

var levelSwitch = new LoggingLevelSwitch();
levelSwitch.MinimumLevel = LogEventLevel.Warning;

var logger = new LoggerConfiguration().WriteTo
    .AmazonS3(
        "log.txt",
        "mytestbucket-aws",
        Amazon.RegionEndpoint.EUWest2,
        "ABCDEFGHIJKLMNOP",
        "c3fghsrgwegfn://asdfsdfsdgfsdg",
        restrictedToMinimumLevel:LogEventLevel.Verbose,
        outputTemplate:"{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}",
        new CultureInfo("de-DE"),
        fileSizeLimitBytes: 200,
        levelSwitch: levelSwitch,
        buffered: true,
        rollingInterval: RollingInterval.Minute,
        retainedFileCountLimit: 10,
        encoding: Encoding.Unicode,
        hooks: new HeaderWriter("Timestamp,Level,Message"))
    .CreateLogger();

    for (var x = 0; x < 200; x++)
    {
        var ex = new Exception("Test");
        logger.Error(ex.ToString());
    }

Further links

  • Overview over the Amazon endpoints and locations: https://docs.aws.amazon.com/general/latest/gr/rande.html
  • How to prepare your S3 bucket to access it with a software: https://www.c-sharpcorner.com/article/fileupload-to-aws-s3-using-asp-net/
  • Example on how to use the Amazon S3 API for .Net: https://stackoverflow.com/questions/25814972/how-to-upload-a-file-to-amazon-s3-super-easy-using-c-sharp

Change history

  • Version 1.0.0.0 (2019-05-31) : 1.0 release.

Serilog.Sinks.AmazonS3

Serilog.Sinks.AmazonS3 is a library to save logging information from Serilog to Amazon S3.
The idea there was to upload log files to Amazon S3 to later evaluate them with Amazon EMR services.
The assembly was written and tested in .Net Framework 4.8 and .Net Standard 2.0.
This project makes use of the Serilog.Sinks.File's code in a major part,
so thanks to all the contributors of this project :thumbsup:.

Build status
GitHub issues
GitHub forks
GitHub stars
GitHub license
Nuget
NuGet Downloads
Known Vulnerabilities

Available for

  • NetFramework 4.5
  • NetFramework 4.6
  • NetFramework 4.6.2
  • NetFramework 4.7
  • NetFramework 4.7.2
  • NetFramework 4.8
  • NetStandard 2.0

Basic usage:

var logger = new LoggerConfiguration().WriteTo
    .AmazonS3(
        "log.txt",
        "mytestbucket-aws",
        Amazon.RegionEndpoint.EUWest2,
        "ABCDEFGHIJKLMNOP",
        "c3fghsrgwegfn://asdfsdfsdgfsdg",
        fileSizeLimitBytes: 200,
        rollingInterval: RollingInterval.Minute)
    .CreateLogger();

    for (var x = 0; x < 200; x++)
    {
        var ex = new Exception("Test");
        logger.Error(ex.ToString());
    }

The project can be found on nuget.

Configuration options:

|Parameter|Meaning|Example|Default value|
|-|-|-|-|
|path|The main log file name used.|&quot;log.txt&quot;|None, is mandatory.|
|bucketName|The name of the Amazon S3 bucket to use. Check: https://docs.aws.amazon.com/general/latest/gr/rande.html.|&quot;mytestbucket-aws&quot;|None, is mandatory.|
|endpoint|The Amazon S3 endpoint location.|RegionEndpoint.EUWest2|None, is mandatory.|
|awsAccessKeyId|The Amazon S3 access key id.|ABCDEFGHIJKLMNOP|None, is mandatory.|
|awsSecretAccessKey|The Amazon S3 secret access key.|c3fghsrgwegfn://asdfsdfsdgfsdg|None, is mandatory.|
|restrictedToMinimumLevel|The minimum level for events passed through the sink. Ignored when levelSwitch is specified. Check: https://github.com/serilog/serilog/blob/dev/src/Serilog/Events/LogEventLevel.cs.|LogEventLevel.Information|LogEventLevel.Verbose|
|outputTemplate|A message template describing the format used to write to the sink.|&quot;{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}&quot;|&quot;{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}&quot;|
|formatProvider|The IFormatProvider to use. Supplies culture-specific formatting information. Check: https://docs.microsoft.com/en-us/dotnet/api/system.iformatprovider?view=netframework-4.8.|new CultureInfo(&quot;de-DE&quot;)|null|
|fileSizeLimitBytes|The number of bytes in a file. The sink rolls to a new file after the limit is reached.|200|1L * 1024 * 1024 * 1024|
|levelSwitch|A switch allowing the pass-through minimum level to be changed at runtime. Check: https://nblumhardt.com/2014/10/dynamically-changing-the-serilog-level/.|var levelSwitch = new LoggingLevelSwitch(); levelSwitch.MinimumLevel = LogEventLevel.Warning;|null|
|buffered|Indicates if flushing to the output file can be buffered or not.|buffered: true|false|
|rollingInterval|The interval at which logging will roll over to a new file. Check: https://github.com/serilog/serilog-sinks-file/blob/dev/src/Serilog.Sinks.File/RollingInterval.cs.|rollingInterval: RollingInterval.Minute|RollingInterval.Day|
|retainedFileCountLimit|The maximum number of log files that will be retained, including the current log file. For unlimited retention, pass null.|10|31|
|encoding|Character encoding used to write the text file. Check: https://docs.microsoft.com/de-de/dotnet/api/system.text.encoding?view=netframework-4.8.|encoding: Encoding.Unicode|null meaning Encoding.UTF8|
|hooks|Optionally enables hooking into log file lifecycle events. Check: https://github.com/serilog/serilog-sinks-file/blob/dev/src/Serilog.Sinks.File/Sinks/File/FileLifecycleHooks.cs and https://github.com/cocowalla/serilog-sinks-file-header/blob/master/src/Serilog.Sinks.File.Header/HeaderWriter.cs.|hooks: new HeaderWriter(&quot;Timestamp,Level,Message&quot;)|null|

Full example

var levelSwitch = new LoggingLevelSwitch();
levelSwitch.MinimumLevel = LogEventLevel.Warning;

var logger = new LoggerConfiguration().WriteTo
    .AmazonS3(
        "log.txt",
        "mytestbucket-aws",
        Amazon.RegionEndpoint.EUWest2,
        "ABCDEFGHIJKLMNOP",
        "c3fghsrgwegfn://asdfsdfsdgfsdg",
        restrictedToMinimumLevel:LogEventLevel.Verbose,
        outputTemplate:"{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}",
        new CultureInfo("de-DE"),
        fileSizeLimitBytes: 200,
        levelSwitch: levelSwitch,
        buffered: true,
        rollingInterval: RollingInterval.Minute,
        retainedFileCountLimit: 10,
        encoding: Encoding.Unicode,
        hooks: new HeaderWriter("Timestamp,Level,Message"))
    .CreateLogger();

    for (var x = 0; x < 200; x++)
    {
        var ex = new Exception("Test");
        logger.Error(ex.ToString());
    }

Further links

  • Overview over the Amazon endpoints and locations: https://docs.aws.amazon.com/general/latest/gr/rande.html
  • How to prepare your S3 bucket to access it with a software: https://www.c-sharpcorner.com/article/fileupload-to-aws-s3-using-asp-net/
  • Example on how to use the Amazon S3 API for .Net: https://stackoverflow.com/questions/25814972/how-to-upload-a-file-to-amazon-s3-super-easy-using-c-sharp

Change history

  • Version 1.0.0.0 (2019-05-31) : 1.0 release.

Release Notes

Version 1.0.0.0 (2019-05-31): 1.0 release.

Dependencies

This package has no dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.2 72 7/25/2019
1.0.1 112 6/23/2019
1.0.0 757 6/1/2019