Inheritance: ITransportConfiguration
Ejemplo n.º 1
0
        /// <summary>
        /// If host/port aren't specified sets to loggly defaults based on selected transport
        /// </summary>
        public static ITransportConfiguration GetCoercedToValidConfig(this ITransportConfiguration input)
        {
            var newConfig = new TransportConfiguration();
            if (input != null)
            {
                newConfig.EndpointHostname = input.EndpointHostname;
                newConfig.EndpointPort = input.EndpointPort;
                newConfig.LogTransport = input.LogTransport;
            }

            if (string.IsNullOrEmpty(newConfig.EndpointHostname))
            {
                newConfig.EndpointHostname = "logs-01.loggly.com";
            }

            if (newConfig.EndpointPort == 0)
            {
                switch (newConfig.LogTransport)
                {
                    case LogTransport.Https:
                        newConfig.EndpointPort = 443;
                        break;
                    case LogTransport.SyslogUdp:
                    case LogTransport.SyslogTcp:
                        newConfig.EndpointPort = 514;
                        break;
                    case LogTransport.SyslogSecure:
                        newConfig.EndpointPort = 6514;
                        break;
                }
            }

            return newConfig;
        }
Ejemplo n.º 2
0
        public async void SendWithSpecificTransport(LogTransport transport)
        {
            var priorTransport = LogglyConfig.Instance.Transport;

            var newTransport = new TransportConfiguration {LogTransport = transport};
            LogglyConfig.Instance.Transport = newTransport.GetCoercedToValidConfig();

            var logEvent = new LogglyEvent();
            logEvent.Data.Add("message", "Log event sent with forced transport={0}", transport);
            await _loggly.Log(logEvent);

            LogglyConfig.Instance.Transport = priorTransport;
        }
        /// <summary>
        /// If host/port aren't specified sets to loggly defaults based on selected transport
        /// </summary>
        public static ITransportConfiguration GetCoercedToValidConfig(this ITransportConfiguration input)
        {
            var newConfig = new TransportConfiguration();

            if (input != null)
            {
                newConfig.EndpointHostname = input.EndpointHostname;
                newConfig.EndpointPort     = input.EndpointPort;
                newConfig.LogTransport     = input.LogTransport;
                newConfig.IsOmitTimestamp  = input.IsOmitTimestamp;
            }

            if (string.IsNullOrEmpty(newConfig.EndpointHostname))
            {
                newConfig.EndpointHostname = "logs-01.loggly.com";
            }

            if (newConfig.EndpointPort == 0)
            {
                switch (newConfig.LogTransport)
                {
                case LogTransport.Https:
                    newConfig.EndpointPort = 443;
                    break;

                case LogTransport.SyslogUdp:
                case LogTransport.SyslogTcp:
                    newConfig.EndpointPort = 514;
                    break;

                case LogTransport.SyslogSecure:
                    newConfig.EndpointPort = 6514;
                    break;
                }
            }

            return(newConfig);
        }
Ejemplo n.º 4
0
 private LogglyConfig()
 {
     IsEnabled = true;
     Tags = new TagConfiguration();
     Transport = new TransportConfiguration();
 }
Ejemplo n.º 5
0
 private LogglyConfig()
 {
     IsEnabled = true;
     TagConfig = new TagConfiguration();
     Transport = new TransportConfiguration();
 }