/// <summary>
        /// Writes a log message to the logger destination.
        /// </summary>
        /// <param name="level">a log level.</param>
        /// <param name="correlationId">(optional) transaction id to trace execution through call chain.</param>
        /// <param name="error">an error object associated with this message.</param>
        /// <param name="message">a human-readable message to log.</param>
        protected override void Write(LogLevel level, string correlationId, Exception error, string message)
        {
            ErrorDescription errorDescription = error != null?ErrorDescriptionFactory.Create(error, correlationId) : null;

            LogMessage logMessage = new LogMessage()
            {
                Time          = DateTime.UtcNow,
                Level         = LogLevelConverter.ToString(level),
                Source        = _source,
                Error         = errorDescription,
                Message       = message,
                CorrelationId = correlationId
            };

            lock (_lock)
            {
                _cache.Add(logMessage);
            }

            Update();
        }
예제 #2
0
 /// <summary>
 /// Configures component by passing configuration parameters.
 /// </summary>
 /// <param name="config">configuration parameters to be set.</param>
 public virtual void Configure(ConfigParams config)
 {
     _level = LogLevelConverter.ToLogLevel(
         config.GetAsObject("level") ?? _level);
     _source = config.GetAsStringWithDefault("source", _source);
 }