HaemmerElectronics.SeppPenner.Serilog.Sinks.AmazonS3
1.0.0
Prefix Reserved
See the version list below for details.
dotnet add package HaemmerElectronics.SeppPenner.Serilog.Sinks.AmazonS3 --version 1.0.0
NuGet\Install-Package HaemmerElectronics.SeppPenner.Serilog.Sinks.AmazonS3 -Version 1.0.0
<PackageReference Include="HaemmerElectronics.SeppPenner.Serilog.Sinks.AmazonS3" Version="1.0.0" />
paket add HaemmerElectronics.SeppPenner.Serilog.Sinks.AmazonS3 --version 1.0.0
#r "nuget: HaemmerElectronics.SeppPenner.Serilog.Sinks.AmazonS3, 1.0.0"
// Install HaemmerElectronics.SeppPenner.Serilog.Sinks.AmazonS3 as a Cake Addin #addin nuget:?package=HaemmerElectronics.SeppPenner.Serilog.Sinks.AmazonS3&version=1.0.0 // Install HaemmerElectronics.SeppPenner.Serilog.Sinks.AmazonS3 as a Cake Tool #tool nuget:?package=HaemmerElectronics.SeppPenner.Serilog.Sinks.AmazonS3&version=1.0.0
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 👍.
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.|"log.txt"
|None, is mandatory.|
|bucketName|The name of the Amazon S3 bucket to use. Check: https://docs.aws.amazon.com/general/latest/gr/rande.html.|`"mytestbucket-aws"`|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.|"{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}"
|"{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}"
|
|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("de-DE")|
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|
nullmeaning
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("Timestamp,Level,Message")|
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.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 is compatible. net461 was computed. net462 is compatible. net463 was computed. net47 is compatible. net471 was computed. net472 is compatible. net48 is compatible. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
1.1.10 | 44,199 | 8/29/2021 | |
1.1.9 | 3,667 | 8/9/2021 | |
1.1.8 | 6,392 | 7/25/2021 | |
1.1.7 | 2,329 | 6/4/2021 | |
1.1.6 | 845 | 5/15/2021 | |
1.1.5 | 1,272 | 4/29/2021 | |
1.1.4 | 2,223 | 4/7/2021 | |
1.1.3 | 21,852 | 3/31/2021 | |
1.1.2 | 9,675 | 2/27/2021 | |
1.1.1 | 440 | 2/21/2021 | |
1.1.0 | 1,711 | 2/3/2021 | |
1.0.12 | 35,366 | 7/16/2020 | |
1.0.11 | 466 | 7/15/2020 | |
1.0.10 | 10,700 | 6/5/2020 | |
1.0.9 | 24,407 | 5/10/2020 | |
1.0.8 | 9,024 | 3/26/2020 | |
1.0.7 | 669 | 2/9/2020 | |
1.0.6 | 4,115 | 12/9/2019 | |
1.0.5 | 568 | 12/8/2019 | |
1.0.4 | 2,090 | 11/12/2019 | |
1.0.3 | 605 | 11/8/2019 | |
1.0.2 | 898 | 7/25/2019 | |
1.0.1 | 733 | 6/23/2019 | |
1.0.0 | 2,343 | 6/1/2019 |
Version 1.0.0.0 (2019-05-31): 1.0 release.