コード例 #1
0
        public bool Connect(string hostname, string username, string pass)
        {
            // Create new ServiceArgs object to store 
            // connection info
            var connectArgs = new ServiceArgs
            {
                Host = hostname,
                Port = 8089
            };

            service = new Service(connectArgs);

            // Use the Login method to connect
            service.Login(username, pass);

            // Print received token to verify login
            System.Console.WriteLine("Token: ");
            System.Console.WriteLine(" " + service.Token);

            connected = true;

            //receiver = new Receiver(service);

            return connected;

        }
コード例 #2
0
ファイル: Program.cs プロジェクト: RossMerr/serilog
        private static void Main(string[] args)
        {
            var host = "192.168.93.128";
            var userName = "******";
            var password = "******";

            var connectArgs = new ServiceArgs { Host = host, };

            var splunkConnectionInfoInfo = new SplunkConnectionInfo
            {
                ServiceArgs = connectArgs,
                UserName = userName,
                Password = password,
                SplunkEventType = "Serilog",
                SplunkSource = "Serilog.SplunkSample"
            };

            Log.Logger = new LoggerConfiguration()
                .Enrich.With(new ThreadIdEnricher())
                .WriteTo.ColoredConsole(outputTemplate: OutputTemplate)
                .WriteTo.Splunk(splunkConnectionInfoInfo, 3, TimeSpan.FromSeconds(1))
                .CreateLogger();

            var serilogLogger = Log.ForContext<Program>();
            var username = Environment.UserName;

            serilogLogger.Information("Hello from Serilog, running as {Username}!", username);

            var items = Enumerable.Range(1,10);

            foreach (var item in items)
            {
               serilogLogger.Information("Logging an int, what fun {item}", item);
            }

            System.Console.WriteLine("ok");
            Console.ReadLine();
        }
コード例 #3
0
ファイル: Service.cs プロジェクト: sim0629/splunk-sdk-csharp
 /// <summary>
 /// Initializes a new instance of the <see cref="Service"/> class,
 /// with a <see cref="ServiceArgs"/> argument list.
 /// </summary>
 /// <param name="args">The service arguments.</param>
 public Service(ServiceArgs args)
     : base()
 {
     this.InitProperties();
     this.App = args.App;
     this.Host = args.Host == null ? defaultHost : args.Host;
     this.Owner = args.Owner;
     this.Port = args.Port == 0 ? defaultPort : args.Port;
     this.Scheme = args.Scheme == null ? HttpService.DefaultScheme : args.Scheme;
     this.Token = args.Token;
 }