Пример #1
0
        public InfoLogger(string categoryName, IMemoryCache cache, IHttpContextAccessor httpContextAccessor)
        {
            _categoryName        = categoryName;
            _cache               = cache;
            _httpContextAccessor = httpContextAccessor;

            CommonLogData commonData = _httpContextAccessor.GetCommonLogData();

            _userTraceId     = commonData.TraceId;
            _username        = commonData.Username;
            _localIpAddress  = commonData.LocalIP;
            _remoteIpAddress = commonData.RemoteIP;
        }
Пример #2
0
        public TraceLogger(IMemoryCache cache, IHttpContextAccessor httpContextAccessor)
        {
            _cache = cache;
            _httpContextAccessor = httpContextAccessor;

            var request = _httpContextAccessor.HttpContext.Request;

            _source = $"{request.Method} {request.Scheme}://{request.Host}{request.Path}{request.QueryString}";

            CommonLogData commonData = _httpContextAccessor.GetCommonLogData();

            _userTraceId     = commonData.TraceId;
            _username        = commonData.Username;
            _localIpAddress  = commonData.LocalIP;
            _remoteIpAddress = commonData.RemoteIP;
        }