SplunkLogger 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package SplunkLogger --version 1.0.2
NuGet\Install-Package SplunkLogger -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SplunkLogger" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SplunkLogger --version 1.0.2
#r "nuget: SplunkLogger, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SplunkLogger as a Cake Addin
#addin nuget:?package=SplunkLogger&version=1.0.2

// Install SplunkLogger as a Cake Tool
#tool nuget:?package=SplunkLogger&version=1.0.2

SplunkLogger

This is a C# .Net Core 2 Splunk ILogger implementation developed at VTEX to send log to Splunk

Package Name Release
SplunkLogger NuGet

It was developed to be integrated to .Net Core 2 logging abstractions.

Features

  • ILoggerProviders (SplunkHECJsonLoggerProvider, SplunkHECRawLoggerProvider, SplunkTcpLoggerProvider and SplunkUdpLoggerProvider)
  • ILoggers (HEC (Raw and Json) and Socket (TCP and UDP)
  • Custom Configurations
  • Batch Manager class (Improve Splunk HEC performance sending data as batch)

Usage

After add SplunkLogger nuget library

PM> Install-Package SplunkLogger

You should 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();
}

In this case above we added a Splunk HEC Raw logger without any custom formmater 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 and for that we created this VTEXSplunkLogger library.

This project contains all VTEX extra classes designed to facilitate to log registration and also, all classes to customize .Net Core 2 log abstraction to a customized log entry at Splunk

Package Name Release
VTEXSplunkLogger MyGet

Features

  • ILoggerExtensions (Allow easy log creation)
  • LoggerFactoryExtensions (Simplify loggerFactory add provider method call)
  • VTEXSplunkLoggerFormatter (Custom ILoggerFormatter responsable for create VTEX custom text to Splunk)

Usage

After add VTEXSplunkLogger nuget library

PM> Install-Package VTEXSplunkLogger -Version 1.0.0 -Source https://www.myget.org/F/vtexlab/api/v3/index.json

You should 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)
{
    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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 69,600 5/21/2018
1.1.2 1,129 4/20/2018
1.1.1 1,868 3/15/2018
1.1.0 1,036 2/26/2018
1.0.8 968 2/23/2018
1.0.7 900 2/22/2018
1.0.6 990 2/22/2018
1.0.5 976 2/21/2018
1.0.4 870 2/21/2018
1.0.3 1,611 1/11/2018
1.0.2 1,178 1/11/2018
1.0.1 1,140 1/10/2018
1.0.0 1,232 1/10/2018