public void Forward(LogObject log) { lock (syncRoot) { if (buffer.Count > BufferLength) { InnerForwarder.Forward(buffer); buffer.Clear(); } buffer.Add(log); } }
private PropertiesDictionary GetLog4netProperties(LogObject log) { PropertiesDictionary lp = new PropertiesDictionary(); if (log.Properties != null) { foreach (var k in log.Properties.Keys) { lp[k] = log.Properties[k]; } } return lp; }
private LoggingEvent Convert(LogObject log) { LoggingEventData led = new LoggingEventData() { LoggerName = log.Namespace, TimeStamp = log.Timestamp, ExceptionString = log.Exception, Message = log.Message, UserName = log.UserName, Level = ToLog4netLevel(log.Level), Properties = GetLog4netProperties(log) }; return new LoggingEvent(led); }
public void Forward(LogObject log) { var channel = this.Connection.GetModel(); IBasicProperties properties = channel.CreateBasicProperties(); properties.Type = log.GetType().Name; properties.ContentEncoding = (this.Serializer.Encoding ?? this.DefaultContentEncoding).WebName; properties.ContentType = this.Serializer.ContentType ?? this.DefaultContentType; properties.Headers = new Dictionary<string, object>(); properties.Headers.Add("SerializerType", Serializer.GetType().Name); // Publishing key format: Namespace.Level string routingKey = string.Format("{0}.{1}", log.Namespace ?? DefaultNamespace, log.Level.ToString()); // Serialize the message byte[] bytes = Serializer.Serialize(log); channel.BasicPublish(this.PublicationAddress.ExchangeName, routingKey, this.PublishMandatory, this.PublishImmediate, properties, bytes); }
public byte[] Serialize(LogObject log) { var str = ServiceStack.Text.JsonSerializer.SerializeToString<LogObject>(log); return this.Encoding.GetBytes(str); }