/// <summary> /// Get custom or default Splunk log formatter /// </summary> /// <param name="splunkLogSettings">Splunk log settings</param> /// <returns></returns> private ITextFormatter GetSplunkLogFormatter(SplunkLogSettings splunkLogSettings) { var textFormatter = this.OutputConfiguration.Splunk.Options.TextFormatter; if (textFormatter == null) { return(new SplunkJsonFormatter(splunkLogSettings)); } return(textFormatter); }
/// <summary> /// Get Splunk log settings /// </summary> /// <returns></returns> private SplunkLogSettings GetSplunkLogSettings() { var splunkLogSettings = new SplunkLogSettings { Application = this.OutputConfiguration.Splunk.Options.Application, Index = this.OutputConfiguration.Splunk.Options.Index, ProcessName = this.OutputConfiguration.Splunk.Options.ProcessName, ProductCompany = this.OutputConfiguration.Splunk.Options.Company, ProductVersion = this.OutputConfiguration.Splunk.Options.ProductVersion, ServerURL = this.OutputConfiguration.Splunk.Options.Url, SourceType = this.OutputConfiguration.Splunk.Options.SourceType, Token = this.OutputConfiguration.Splunk.Options.Token }; return(splunkLogSettings); }
public static void Build_Basics_Logger_With_Json_Formatter() { // arrage LoggerBuilder builder = new LoggerBuilder(); SeqOptions seqOptions = new SeqOptions { Url = "http://localhost", ApiKey = "123456" }; var splunkSettings = new SplunkLogSettings(); splunkSettings.ServerURL = "http://localhost"; splunkSettings.Token = "123456"; splunkSettings.Index = "my.index"; SplunkOptions splunkOptions = new SplunkOptions { Enabled = true, Url = "http://localhost", Token = "123456", Index = "my.index", TextFormatter = new SplunkJsonFormatter(splunkSettings) }; Log.Logger = builder .UseSuggestedSetting("MyDomain", "MyApplication") .SetupSeq(seqOptions) .SetupSplunk(splunkOptions) .BuildLogger(); // act var logger = builder.BuildLogger(); // assert Assert.NotNull(logger); }