Example #1
0
        public Microsoft.Extensions.Logging.ILogger CreateLogger(string categoryName)
        {
            LuccaLoggerOptions opt = _options.CurrentValue;
            var logExtractor       = new LogExtractor(_logDetailsExtractors, new EnvironmentDetailsExtractor(opt));

            return(new LuccaLogger(categoryName, _httpContextAccessor, LogManager.GetLogger(categoryName), opt, logExtractor, _filters, _exceptionalWrapper, _options.CurrentValue.ApplicationName));
        }
Example #2
0
 public LuccaLogger(string categoryName, IHttpContextParser httpContextAccessor, Logger nloLogger, LuccaLoggerOptions options, LogExtractor logExtractor, IExceptionQualifier filters, IExceptionalWrapper exceptionalWrapper, string appName)
 {
     _categoryName       = categoryName;
     _httpContextWrapper = httpContextAccessor;
     _nloLogger          = nloLogger;
     _logExtractor       = logExtractor;
     _options            = options;
     _filters            = filters;
     _exceptionalWrapper = exceptionalWrapper;
     _appName            = appName;
 }
Example #3
0
        private void PropagateOptions(LuccaLoggerOptions options)
        {
            LogManager.Configuration = options.Nlog;

            _exceptionalWrapper.Configure(exceptionalSetting =>
            {
                exceptionalSetting.DefaultStore = options.GenerateExceptionalStore();

                exceptionalSetting.LogFilters.Cookie["password"]      = "******";
                exceptionalSetting.LogFilters.Header["password"]      = "******";
                exceptionalSetting.LogFilters.Form["password"]        = "******";
                exceptionalSetting.LogFilters.Header["password"]      = "******";
                exceptionalSetting.LogFilters.QueryString["password"] = "******";

                exceptionalSetting.OnBeforeLog += (o, eb) =>
                {
                    var querystring = eb?.Error?.ServerVariables?.Get("QUERY_STRING");
                    if (querystring != null)
                    {
                        eb.Error.ServerVariables.Set("QUERY_STRING", querystring.ClearQueryStringPassword());
                    }
                };
            });
        }
Example #4
0
        private static void AppendLuccaData(Guid?guid, LogEventInfo eventInfo, LuccaLoggerOptions options, Dictionary <string, string> customData)
        {
            foreach (KeyValuePair <string, string> kv in customData)
            {
                if (kv.Key != LogMeta.RawPostedData)
                {
                    eventInfo.Properties[kv.Key] = kv.Value;
                }
            }

            if (!guid.HasValue)
            {
                return;
            }

            if (options.GuidWithPlaceHolder)
            {
                eventInfo.Properties[LogMeta.Link] = String.Format(options.GuidLink, guid.Value.ToString("N"));
            }
            else
            {
                eventInfo.Properties[LogMeta.Link] = options.GuidLink + guid.Value.ToString("N");
            }
        }
Example #5
0
 public EnvironmentDetailsExtractor(LuccaLoggerOptions options)
 {
     _options = options;
 }