示例#1
0
        /// <summary>
        /// Adds a sink that writes log events as to a Splunk instance via http.
        /// </summary>
        /// <param name="loggerConfiguration">The logger config</param>
        /// <param name="host">The Splunk host that is configured for UDP logging</param>
        /// <param name="port">The UDP port</param>
        /// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
        /// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
        /// <returns></returns>
        /// <remarks>TODO: Add link to splunk configuration and wiki</remarks>
        public static LoggerConfiguration SplunkViaUdp(
            this LoggerSinkConfiguration loggerConfiguration,
            string host,
            int port,
            LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
            IFormatProvider formatProvider         = null)
        {
            var sink = new SplunkViaUdpSink(host, port, formatProvider);

            return(loggerConfiguration.Sink(sink, restrictedToMinimumLevel));
        }
        /// <summary>
        /// Adds a sink that writes log events as to a Splunk instance via UDP.
        /// </summary>
        /// <param name="loggerConfiguration">The logger config</param>
        /// <param name="hostAddresss">The Splunk host that is configured for UDP logging</param>
        /// <param name="port">The UDP port</param>
        /// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
        /// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
        /// <param name="renderTemplate">If ture, the message template is rendered</param>
        /// <returns>The logger configuration</returns>
        /// <remarks>TODO: Add link to splunk configuration and wiki</remarks>
        public static LoggerConfiguration SplunkViaUdp(
            this LoggerSinkConfiguration loggerConfiguration,
            IPAddress hostAddresss,
            int port,
            LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
            IFormatProvider formatProvider         = null,
            bool renderTemplate = true)
        {
            var sink = new SplunkViaUdpSink(hostAddresss, port, formatProvider, renderTemplate);

            return(loggerConfiguration.Sink(sink, restrictedToMinimumLevel));
        }