SplunkLogger 1.0.5
See the version list below for details.
dotnet add package SplunkLogger --version 1.0.5
NuGet\Install-Package SplunkLogger -Version 1.0.5
<PackageReference Include="SplunkLogger" Version="1.0.5" />
paket add SplunkLogger --version 1.0.5
#r "nuget: SplunkLogger, 1.0.5"
// Install SplunkLogger as a Cake Addin #addin nuget:?package=SplunkLogger&version=1.0.5 // Install SplunkLogger as a Cake Tool #tool nuget:?package=SplunkLogger&version=1.0.5
SplunkLogger
This is a C# .Net Core 2 Splunk ILogger implementation developed at VTEX to send log to Splunk
Package Name | Release |
---|---|
SplunkLogger |
It was developed to be integrated to .Net Core 2 logging abstractions.
Features
- ILoggers HEC (Raw and Json) and Socket (TCP and UDP)
- Batch Manager class (Improve Splunk HEC performance sending data as batch)
Usage
Add SplunkLogger nuget library
PM> Install-Package SplunkLogger
Initialize a new SplunkLoggerConfiguration and the logger provider at Configure method at Startup class:
static readonly ILoggerFormatter formatter = null;
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
var splunkConfiguration = new SplunkLoggerConfiguration()
{
HecConfiguration = new HECConfiguration()
{
SplunkCollectorUrl = "https://localhost:8088/services/collector",
Token = "753c5a9c-fb59-4da0-9064-947f99dc20ba"
}
};
loggerFactory.AddHECRawSplunkLogger(splunkConfiguration, formatter);
app.UseMvc();
}
The case above is using a Splunk HEC Raw logger without any custom formatter as log provider.
Now, in your controller you can log normally, for instance:
[Route("api/[controller]")]
public class ValuesController : Controller
{
readonly ILogger logger;
public ValuesController(ILoggerFactory loggerFactory)
{
logger = loggerFactory.CreateLogger<ValuesController>();
}
// GET api/values
[HttpGet]
public IEnumerable<string> Get()
{
logger.LogCritical(new EventId(-1, "Values Controller"), new NotImplementedException(), "Error on GET api/values route");
return new string[] { "value1", "value2" };
}
}
VTEXSplunkLogger
For us at VTEX we need more customized log entries at Splunk and also we need easier ways to call for log registration during the code. For that, we created this VTEXSplunkLogger library.
This project contains all VTEX extra classes designed to ease logging. All classes changes .Net Core 2 log abstraction to a customized log entry at Splunk
Package Name | Release |
---|---|
VTEXSplunkLogger |
Features
- ILoggerExtensions (Allow easy log creation)
- LoggerFactoryExtensions (Simplify loggerFactory add provider method call)
- VTEXSplunkLoggerFormatter (Custom
ILoggerFormatter
which creates VTEX's custom text to Splunk)
Usage
Add VTEXSplunkLogger nuget library
PM> Install-Package VTEXSplunkLogger -Source https://www.myget.org/F/vtexlab/api/v3/index.json
Initialize a new SplunkLoggerConfiguration and the logger provider at Configure method at Startup class:
static readonly ILoggerFormatter formatter = new VTEXSplunkLoggerFormatter();
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
//TODO: Set your project name
ILoggerExtensions.SetApplication("ProjectX");
var splunkConfiguration = new SplunkLoggerConfiguration()
{
HecConfiguration = new HECConfiguration()
{
SplunkCollectorUrl = "https://localhost:8088/services/collector",
Token = "753c5a9c-fb59-4da0-9064-947f99dc20ba"
}
};
loggerFactory.AddHECRawSplunkLogger(splunkConfiguration, formatter);
app.UseMvc();
}
using Vtex;
// other usings ..
[Route("api/[controller]")]
public class ValuesController : Controller
{
readonly ILogger logger;
public ValuesController(ILoggerFactory loggerFactory)
{
logger = loggerFactory.CreateLogger<ValuesController>();
}
// GET api/values
[HttpGet]
public IEnumerable<string> Get()
{
logger.DefineVTEXLog(LogLevel.Critical,
"Values Controller",
"api/values",
string.Empty,
new NotImplementedException(),
new Tuple<string, string>("method", "GET"));
return new string[] { "value1", "value2" };
}
}
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. |
.NET Core | netcoreapp2.0 is compatible. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
-
.NETCoreApp 2.0
- Microsoft.Extensions.Logging (>= 2.0.0)
- Newtonsoft.Json (>= 10.0.3)
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.3 | 73,623 | 5/21/2018 |
1.1.2 | 1,171 | 4/20/2018 |
1.1.1 | 1,890 | 3/15/2018 |
1.1.0 | 1,078 | 2/26/2018 |
1.0.8 | 999 | 2/23/2018 |
1.0.7 | 934 | 2/22/2018 |
1.0.6 | 1,033 | 2/22/2018 |
1.0.5 | 1,009 | 2/21/2018 |
1.0.4 | 898 | 2/21/2018 |
1.0.3 | 1,652 | 1/11/2018 |
1.0.2 | 1,222 | 1/11/2018 |
1.0.1 | 1,172 | 1/10/2018 |
1.0.0 | 1,266 | 1/10/2018 |