Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="filter"></param>
        /// <param name="configuration"></param>
        public SplunkLogger(string name, Func <string, LogLevel, Exception, bool> filter, SplunkConfiguration configuration)
        {
            Filter    = filter ?? ((category, logLevel, exception) => true);
            this.name = name;

            hecSender = new HttpEventCollectorSender(
                configuration.ServerUrl,                                                         // Splunk HEC URL
                configuration.Token,                                                             // Splunk HEC token *GUID*
                new HttpEventCollectorEventInfo.Metadata(null, null, "_json", GetMachineName()), // Metadata
                HttpEventCollectorSender.SendMode.Sequential,                                    // Sequential sending to keep message in order
                0,                                                                               // BatchInterval - Set to 0 to disable
                0,                                                                               // BatchSizeBytes - Set to 0 to disable
                0,                                                                               // BatchSizeCount - Set to 0 to disable
                new HttpEventCollectorResendMiddleware(configuration.RetriesOnError).Plugin,     // Resend Middleware with retry
                configuration.Formatter);

            hecSender.OnError += configuration.OnError;
        }
Exemple #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="filter"></param>
 /// <param name="configuration"></param>
 public SplunkLoggerProvider(Func <string, LogLevel, Exception, bool> filter, SplunkConfiguration configuration)
 {
     this.filter        = filter;
     this.configuration = configuration;
 }