protected override void InitializeTarget() { base.InitializeTarget(); _settings = new LumberjackClientSettings { Host = Host, Port = Port, ConnectRetryCount = ConnectRetryCount, CloseTimeout = CloseTimeout, SendBufferSize = SendBufferSize, ReceiveBufferSize = ReceiveBufferSize, SendFull = SendFull, SendConfirm = SendConfirm, }; _client = new LumberjackClient.LumberjackClient(_settings); if (Header != null) { var kvs = new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>("@timestamp", DateTime.UtcNow.ToString("o")), new KeyValuePair<string, string>("message", Header.Render(LogEventInfo.CreateNullEvent())) }; if (Fields != null) kvs.AddRange(Fields); _client.Send(kvs); } }
public override void ActivateOptions() { base.ActivateOptions(); _settings = new LumberjackClientSettings { Host = Host, Port = Port, ConnectRetryCount = ConnectRetryCount, CloseTimeout = CloseTimeout, SendBufferSize = SendBufferSize, ReceiveBufferSize = ReceiveBufferSize, SendFull = SendFull, SendConfirm = SendConfirm, }; _client = new LumberjackClient.LumberjackClient(_settings); }
private static void Main(string[] args) { var settings = new LumberjackClientSettings { Host = "localhost", Port = 5000 }; var client = new LumberjackClient.LumberjackClient(settings); for (int i = 0; i < 100; i++) { client.Send( new KeyValuePair<string, string>("host", Environment.MachineName), new KeyValuePair<string, string>("message", "Test Message " + i), new KeyValuePair<string, string>("key1", "value1"), new KeyValuePair<string, string>("key2", "value2"), new KeyValuePair<string, string>("key3", "value3")); if (i % 10 == 0) Thread.Sleep(10); } Console.WriteLine("Done!"); Thread.Sleep(1000000); }