Exemple #1
0
        public void Forward(LogObject log)
        {
            lock (syncRoot)
            {
                if (buffer.Count > BufferLength)
                {
                    InnerForwarder.Forward(buffer);
                    buffer.Clear();
                }

                buffer.Add(log);
            }
        }
Exemple #2
0
        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;
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
 public byte[] Serialize(LogObject log)
 {
     var str = ServiceStack.Text.JsonSerializer.SerializeToString<LogObject>(log);
     return this.Encoding.GetBytes(str);
 }