protected override Task <bool> WriteLog(TraceEventType level, LogCallSiteInfo logCallSiteInfo, string message,
                                                IDictionary <string, string> encryptedTags, IDictionary <string, string> unencryptedTags, Exception exception = null, string stackTrace = null)
        {
            var log = FormatLogEntry(level, message, encryptedTags.Concat(unencryptedTags)
                                     .Where(_ => _.Value != null)
                                     .ToList(), exception);

            Trace.WriteLine(log);

            return(Task.FromResult(true));
        }
示例#2
0
        protected override Task <bool> WriteLog(TraceEventType level, LogCallSiteInfo logCallSiteInfo, string message,
                                                IDictionary <string, string> encryptedTags, IDictionary <string, string> unencryptedTags, Exception exception = null, string stackTrace = null)
        {
            var str = FormatLogEntry(level, message, encryptedTags.Concat(unencryptedTags)
                                     .Where(_ => _.Value != null)
                                     .ToList(), exception);

            httpClient.PostAsync(HttpLogUrl, new StringContent($"{AppDomain.CurrentDomain.FriendlyName}: {str}"));

            return(Task.FromResult(true));
        }
示例#3
0
        public SerilogLogger(Type receivingType)
        {
            AssemblyName reflectedAssembly = receivingType.Assembly.GetName();

            CallSiteInfoTemplate = new LogCallSiteInfo
            {
                ReflectedType   = receivingType,
                ClassName       = receivingType.Name,
                AssemblyName    = reflectedAssembly.Name,
                AssemblyVersion = reflectedAssembly.Version.ToString(),
            };
        }
示例#4
0
        protected override Task <bool> WriteLog(TraceEventType level, LogCallSiteInfo logCallSiteInfo,
                                                string message, IDictionary <string, string> encryptedTags, IDictionary <string, string> unencryptedTags,
                                                Exception exception = null, string stackTrace = null)
        {
            var logLevel = ToLogLevel(level);

            if (Log.Logger.IsEnabled(logLevel))
            {
                var messageWithTags = message + " " + string.Join(", ", unencryptedTags.Select(kvp => $"{kvp.Key.Substring(5)}={EventFieldFormatter.SerializeFieldValue(kvp.Value)}")) + ". ";
                Log.Logger.Write(logLevel, exception, messageWithTags);
            }

            return(Task.FromResult(true));
        }
示例#5
0
        protected FakeLog()
        {
            var          ReceivingType     = typeof(object);
            AssemblyName reflectedAssembly = ReceivingType.Assembly.GetName();

            CallSiteInfoTemplate = new LogCallSiteInfo
            {
                ReflectedType   = ReceivingType,
                ClassName       = ReceivingType.Name,
                AssemblyName    = reflectedAssembly.Name,
                AssemblyVersion = reflectedAssembly.Version.ToString(),
                BuildTime       = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
            };
        }
        public NLogLogger(Type receivingType)
        {
            Logger = LogManager.GetLogger(receivingType.FullName);

            AssemblyName reflectedAssembly = receivingType.Assembly.GetName();

            CallSiteInfoTemplate = new LogCallSiteInfo
            {
                ReflectedType   = receivingType,
                ClassName       = receivingType.Name,
                AssemblyName    = reflectedAssembly.Name,
                AssemblyVersion = reflectedAssembly.Version.ToString(),
            };
        }
        public SerilogLogger(Type receivingType)
        {
            Log.Logger = new LoggerConfiguration()
                         .ReadFrom.AppSettings()
                         .CreateLogger();

            AssemblyName reflectedAssembly = receivingType.Assembly.GetName();

            CallSiteInfoTemplate = new LogCallSiteInfo
            {
                ReflectedType   = receivingType,
                ClassName       = receivingType.Name,
                AssemblyName    = reflectedAssembly.Name,
                AssemblyVersion = reflectedAssembly.Version.ToString(),
            };
        }
示例#8
0
        protected override Task <bool> WriteLog(TraceEventType severity, LogCallSiteInfo logCallSiteInfo, string message, IDictionary <string, string> encryptedTags, IDictionary <string, string> unencryptedTags, Exception exception = null, string stackTrace = null)
        {
            var entry = new LogEntry
            {
                Severity        = severity,
                Message         = message,
                EncryptedTags   = encryptedTags.ToDictionary(_ => _.Key, _ => EventFieldFormatter.SerializeFieldValue(_.Value)),
                UnencryptedTags = unencryptedTags.ToDictionary(_ => _.Key, _ => EventFieldFormatter.SerializeFieldValue(_.Value)),
                Exception       = exception
            };

            lock (LogEntriesList)
            {
                LogEntriesList.Add(entry);
            }

            return(null);
        }
示例#9
0
 protected override Task <bool> WriteLog(TraceEventType level, LogCallSiteInfo logCallSiteInfo, string message, IDictionary <string, string> encryptedTags, IDictionary <string, string> unencryptedTags, Exception exception = null, string stackTrace = null)
 {
     return(Task.FromResult(true));
 }