Exemplo n.º 1
0
 /// <summary>
 /// User implementable log method (e.g. what actions they need to take to perform
 /// a "log" operation, like logging to a file for example).
 /// </summary>
 /// <param name="message"></param>
 protected abstract void log(LoggerMessage message);
Exemplo n.º 2
0
        static RewriteMiddlewareLoggingExtensions()
        {
            _requestContinueResults = LoggerMessage.Define <string>(
                LogLevel.Debug,
                1,
                "Request is continuing in applying rules. Current url is {currentUrl}");

            _requestResponseComplete = LoggerMessage.Define <string, int>(
                LogLevel.Debug,
                2,
                "Request is done processing. Location header '{Location}' with status code '{StatusCode}'.");

            _requestStopRules = LoggerMessage.Define <string>(
                LogLevel.Debug,
                3,
                "Request is done applying rules. Url was rewritten to {rewrittenUrl}");

            _urlRewriteDidNotMatchRule = LoggerMessage.Define <string>(
                LogLevel.Debug,
                4,
                "Request did not match current rule '{Name}'.");

            _urlRewriteMatchedRule = LoggerMessage.Define <string>(
                LogLevel.Debug,
                5,
                "Request matched current UrlRewriteRule '{Name}'.");

            _modRewriteDidNotMatchRule = LoggerMessage.Define(
                LogLevel.Debug,
                6,
                "Request matched current ModRewriteRule.");

            _modRewriteMatchedRule = LoggerMessage.Define(
                LogLevel.Debug,
                7,
                "Request matched current ModRewriteRule.");

            _redirectedToHttps = LoggerMessage.Define(
                LogLevel.Information,
                8,
                "Request redirected to HTTPS");

            _redirectSummary = LoggerMessage.Define <string>(
                LogLevel.Information,
                9,
                "Request was redirected to {redirectedUrl}");

            _rewriteSummary = LoggerMessage.Define <string>(
                LogLevel.Information,
                10,
                "Request was rewritten to {rewrittenUrl}");

            _abortedRequest = LoggerMessage.Define <string>(
                LogLevel.Debug,
                11,
                "Request to {requestedUrl} was aborted");

            _customResponse = LoggerMessage.Define <string>(
                LogLevel.Debug,
                12,
                "Request to {requestedUrl} was ended");
        }
 public static Action <ILogger, T1, T2, T3, T4, T5, T6, Exception?> Define <T1, T2, T3, T4, T5, T6>(
     LogEvent logEvent) =>
 LoggerMessage.Define <T1, T2, T3, T4, T5, T6>(logEvent.Level, logEvent.EventId, logEvent.Message);
Exemplo n.º 4
0
 protected override void log(LoggerMessage message)
 {
     if (stream == null) return;
     string time = System.DateTime.FromFileTime(message.time).ToString();
     string test = "[" + time + " [" + message.level + ":" + message.level_desc + " (" + message.tag + ")] " + message.message + " ]\r\n";
     stream.Write("[" + time + " [" + message.level + ":" + message.level_desc + " (" + message.tag + ")] " + message.message + " ]\r\n");
 }
Exemplo n.º 5
0
 static ScopeInfoWithThreeParameters()
 {
     ScopeDelegate = LoggerMessage.DefineScope <string, string, int>(NamedStringFormat);
 }
 static LoggerExtensions()
 {
     _requestMethodNotCacheable = LoggerMessage.Define<string>(
         logLevel: LogLevel.Debug,
         eventId: new EventId(1, "RequestMethodNotCacheable"),
         formatString: "The request cannot be served from cache because it uses the HTTP method: {Method}.");
     _requestWithAuthorizationNotCacheable = LoggerMessage.Define(
         logLevel: LogLevel.Debug,
         eventId: new EventId(2, "RequestWithAuthorizationNotCacheable"),
         formatString: $"The request cannot be served from cache because it contains an '{HeaderNames.Authorization}' header.");
     _requestWithNoCacheNotCacheable = LoggerMessage.Define(
         logLevel: LogLevel.Debug,
         eventId: new EventId(3, "RequestWithNoCacheNotCacheable"),
         formatString: "The request cannot be served from cache because it contains a 'no-cache' cache directive.");
     _requestWithPragmaNoCacheNotCacheable = LoggerMessage.Define(
         logLevel: LogLevel.Debug,
         eventId: new EventId(4, "RequestWithPragmaNoCacheNotCacheable"),
         formatString: "The request cannot be served from cache because it contains a 'no-cache' pragma directive.");
     _expirationMinFreshAdded = LoggerMessage.Define<TimeSpan>(
         logLevel: LogLevel.Debug,
         eventId: new EventId(5, "LogRequestMethodNotCacheable"),
         formatString: "Adding a minimum freshness requirement of {Duration} specified by the 'min-fresh' cache directive.");
     _expirationSharedMaxAgeExceeded = LoggerMessage.Define<TimeSpan, TimeSpan>(
         logLevel: LogLevel.Debug,
         eventId: new EventId(6, "ExpirationSharedMaxAgeExceeded"),
         formatString: "The age of the entry is {Age} and has exceeded the maximum age for shared caches of {SharedMaxAge} specified by the 's-maxage' cache directive.");
     _expirationMustRevalidate = LoggerMessage.Define<TimeSpan, TimeSpan>(
         logLevel: LogLevel.Debug,
         eventId: new EventId(7, "ExpirationMustRevalidate"),
         formatString: "The age of the entry is {Age} and has exceeded the maximum age of {MaxAge} specified by the 'max-age' cache directive. It must be revalidated because the 'must-revalidate' or 'proxy-revalidate' cache directive is specified.");
     _expirationMaxStaleSatisfied = LoggerMessage.Define<TimeSpan, TimeSpan, TimeSpan>(
         logLevel: LogLevel.Debug,
         eventId: new EventId(8, "ExpirationMaxStaleSatisfied"),
         formatString: "The age of the entry is {Age} and has exceeded the maximum age of {MaxAge} specified by the 'max-age' cache directive. However, it satisfied the maximum stale allowance of {MaxStale} specified by the 'max-stale' cache directive.");
     _expirationMaxAgeExceeded = LoggerMessage.Define<TimeSpan, TimeSpan>(
         logLevel: LogLevel.Debug,
         eventId: new EventId(9, "ExpirationMaxAgeExceeded"),
         formatString: "The age of the entry is {Age} and has exceeded the maximum age of {MaxAge} specified by the 'max-age' cache directive.");
     _expirationExpiresExceeded = LoggerMessage.Define<DateTimeOffset, DateTimeOffset>(
         logLevel: LogLevel.Debug,
         eventId: new EventId(10, "ExpirationExpiresExceeded"),
         formatString: $"The response time of the entry is {{ResponseTime}} and has exceeded the expiry date of {{Expired}} specified by the '{HeaderNames.Expires}' header.");
     _responseWithoutPublicNotCacheable = LoggerMessage.Define(
         logLevel: LogLevel.Debug,
         eventId: new EventId(11, "ResponseWithoutPublicNotCacheable"),
         formatString: "Response is not cacheable because it does not contain the 'public' cache directive.");
     _responseWithNoStoreNotCacheable = LoggerMessage.Define(
         logLevel: LogLevel.Debug,
         eventId: new EventId(12, "ResponseWithNoStoreNotCacheable"),
         formatString: "Response is not cacheable because it or its corresponding request contains a 'no-store' cache directive.");
     _responseWithNoCacheNotCacheable = LoggerMessage.Define(
         logLevel: LogLevel.Debug,
         eventId: new EventId(13, "ResponseWithNoCacheNotCacheable"),
         formatString: "Response is not cacheable because it contains a 'no-cache' cache directive.");
     _responseWithSetCookieNotCacheable = LoggerMessage.Define(
         logLevel: LogLevel.Debug,
         eventId: new EventId(14, "ResponseWithSetCookieNotCacheable"),
         formatString: $"Response is not cacheable because it contains a '{HeaderNames.SetCookie}' header.");
     _responseWithVaryStarNotCacheable = LoggerMessage.Define(
         logLevel: LogLevel.Debug,
         eventId: new EventId(15, "ResponseWithVaryStarNotCacheable"),
         formatString: $"Response is not cacheable because it contains a '{HeaderNames.Vary}' header with a value of *.");
     _responseWithPrivateNotCacheable = LoggerMessage.Define(
         logLevel: LogLevel.Debug,
         eventId: new EventId(16, "ResponseWithPrivateNotCacheable"),
         formatString: "Response is not cacheable because it contains the 'private' cache directive.");
     _responseWithUnsuccessfulStatusCodeNotCacheable = LoggerMessage.Define<int>(
         logLevel: LogLevel.Debug,
         eventId: new EventId(17, "ResponseWithUnsuccessfulStatusCodeNotCacheable"),
         formatString: "Response is not cacheable because its status code {StatusCode} does not indicate success.");
     _notModifiedIfNoneMatchStar = LoggerMessage.Define(
         logLevel: LogLevel.Debug,
         eventId: new EventId(18, "ExpirationExpiresExceeded"),
         formatString: $"The '{HeaderNames.IfNoneMatch}' header of the request contains a value of *.");
     _notModifiedIfNoneMatchMatched = LoggerMessage.Define<EntityTagHeaderValue>(
         logLevel: LogLevel.Debug,
         eventId: new EventId(19, "NotModifiedIfNoneMatchMatched"),
         formatString: $"The ETag {{ETag}} in the '{HeaderNames.IfNoneMatch}' header matched the ETag of a cached entry.");
     _notModifiedIfModifiedSinceSatisfied = LoggerMessage.Define<DateTimeOffset, DateTimeOffset>(
         logLevel: LogLevel.Debug,
         eventId: new EventId(20, "NotModifiedIfModifiedSinceSatisfied"),
         formatString: $"The last modified date of {{LastModified}} is before the date {{IfModifiedSince}} specified in the '{HeaderNames.IfModifiedSince}' header.");
     _notModifiedServed = LoggerMessage.Define(
         logLevel: LogLevel.Information,
         eventId: new EventId(21, "NotModifiedServed"),
         formatString: "The content requested has not been modified.");
     _cachedResponseServed = LoggerMessage.Define(
         logLevel: LogLevel.Information,
         eventId: new EventId(22, "CachedResponseServed"),
         formatString: "Serving response from cache.");
     _gatewayTimeoutServed = LoggerMessage.Define(
         logLevel: LogLevel.Information,
         eventId: new EventId(23, "GatewayTimeoutServed"),
         formatString: "No cached response available for this request and the 'only-if-cached' cache directive was specified.");
     _noResponseServed = LoggerMessage.Define(
         logLevel: LogLevel.Information,
         eventId: new EventId(24, "NoResponseServed"),
         formatString: "No cached response available for this request.");
     _varyByRulesUpdated = LoggerMessage.Define<string, string>(
         logLevel: LogLevel.Debug,
         eventId: new EventId(25, "VaryByRulesUpdated"),
         formatString: "Vary by rules were updated. Headers: {Headers}, Query keys: {QueryKeys}");
     _responseCached = LoggerMessage.Define(
         logLevel: LogLevel.Information,
         eventId: new EventId(26, "ResponseCached"),
         formatString: "The response has been cached.");
     _responseNotCached = LoggerMessage.Define(
         logLevel: LogLevel.Information,
         eventId: new EventId(27, "ResponseNotCached"),
         formatString: "The response could not be cached for this request.");
     _responseContentLengthMismatchNotCached = LoggerMessage.Define(
         logLevel: LogLevel.Warning,
         eventId: new EventId(28, "responseContentLengthMismatchNotCached"),
         formatString: $"The response could not be cached for this request because the '{HeaderNames.ContentLength}' did not match the body length.");
     _expirationInfiniteMaxStaleSatisfied = LoggerMessage.Define<TimeSpan, TimeSpan>(
         logLevel: LogLevel.Debug,
         eventId: new EventId(29, "ExpirationInfiniteMaxStaleSatisfied"),
         formatString: "The age of the entry is {Age} and has exceeded the maximum age of {MaxAge} specified by the 'max-age' cache directive. However, the 'max-stale' cache directive was specified without an assigned value and a stale response of any age is accepted.");
 }
 static LoggerExtensions()
 {
     s_timeoutConfigured = LoggerMessage.Define <string, string, TimeSpan>(LogLevel.Information,
                                                                           new EventId(1, "TimeoutConfigured"),
                                                                           "Timeout configured for request with trace-id {traceId} and handle {handle} and set to {timeout}");
 }
Exemplo n.º 8
0
 static ScopeWithoutAnyParameters()
 {
     ScopeDelegate = LoggerMessage.DefineScope(Message);
 }
Exemplo n.º 9
0
 private static Action <ILogger, string, string, string, string, Exception> getRequestLog(LogLevel logLevel)
 {
     return(LoggerMessage.Define <string, string, string, string>(
                logLevel, responseEventId, "请求:{method} {url} {headers} \n {bodyString} "));
 }
Exemplo n.º 10
0
            static Log()
            {
                _initializationStarted = LoggerMessage.Define(
                    LogLevel.Debug,
                    EventIds.InitializationStarted,
                    "Circuit initialization started.");

                _initializationSucceded = LoggerMessage.Define(
                    LogLevel.Debug,
                    EventIds.InitializationSucceeded,
                    "Circuit initialization succeeded.");

                _initializationFailed = LoggerMessage.Define(
                    LogLevel.Debug,
                    EventIds.InitializationFailed,
                    "Circuit initialization failed.");

                _disposeStarted = LoggerMessage.Define <CircuitId>(
                    LogLevel.Debug,
                    EventIds.DisposeStarted,
                    "Disposing circuit '{CircuitId}' started.");

                _disposeSucceeded = LoggerMessage.Define <CircuitId>(
                    LogLevel.Debug,
                    EventIds.DisposeSucceeded,
                    "Disposing circuit '{CircuitId}' succeeded.");

                _disposeFailed = LoggerMessage.Define <CircuitId>(
                    LogLevel.Debug,
                    EventIds.DisposeFailed,
                    "Disposing circuit '{CircuitId}' failed.");

                _onCircuitOpened = LoggerMessage.Define <CircuitId>(
                    LogLevel.Debug,
                    EventIds.OnCircuitOpened,
                    "Opening circuit with id '{CircuitId}'.");

                _onConnectionUp = LoggerMessage.Define <CircuitId, string>(
                    LogLevel.Debug,
                    EventIds.OnConnectionUp,
                    "Circuit id '{CircuitId}' connected using connection '{ConnectionId}'.");

                _onConnectionDown = LoggerMessage.Define <CircuitId, string>(
                    LogLevel.Debug,
                    EventIds.OnConnectionDown,
                    "Circuit id '{CircuitId}' disconnected from connection '{ConnectionId}'.");

                _onCircuitClosed = LoggerMessage.Define <CircuitId>(
                    LogLevel.Debug,
                    EventIds.OnCircuitClosed,
                    "Closing circuit with id '{CircuitId}'.");

                _circuitHandlerFailed = LoggerMessage.Define <Type, string, string>(
                    LogLevel.Error,
                    EventIds.CircuitHandlerFailed,
                    "Unhandled error invoking circuit handler type {handlerType}.{handlerMethod}: {Message}");

                _circuitUnhandledException = LoggerMessage.Define <CircuitId>(
                    LogLevel.Error,
                    EventIds.CircuitUnhandledException,
                    "Unhandled exception in circuit '{CircuitId}'.");

                _circuitTransmittingClientError = LoggerMessage.Define <CircuitId>(
                    LogLevel.Debug,
                    EventIds.CircuitTransmittingClientError,
                    "About to notify client of an error in circuit '{CircuitId}'.");

                _circuitTransmittedClientErrorSuccess = LoggerMessage.Define <CircuitId>(
                    LogLevel.Debug,
                    EventIds.CircuitTransmittedClientErrorSuccess,
                    "Successfully transmitted error to client in circuit '{CircuitId}'.");

                _circuitTransmitErrorFailed = LoggerMessage.Define <CircuitId>(
                    LogLevel.Debug,
                    EventIds.CircuitTransmitErrorFailed,
                    "Failed to transmit exception to client in circuit '{CircuitId}'.");

                _unhandledExceptionClientDisconnected = LoggerMessage.Define <CircuitId>(
                    LogLevel.Debug,
                    EventIds.UnhandledExceptionClientDisconnected,
                    "An exception occurred on the circuit host '{CircuitId}' while the client is disconnected.");

                _beginInvokeDotNetStatic = LoggerMessage.Define <string, string, string>(
                    LogLevel.Debug,
                    EventIds.BeginInvokeDotNet,
                    "Invoking static method with identifier '{MethodIdentifier}' on assembly '{Assembly}' with callback id '{CallId}'.");

                _beginInvokeDotNetInstance = LoggerMessage.Define <string, long, string>(
                    LogLevel.Debug,
                    EventIds.BeginInvokeDotNet,
                    "Invoking instance method '{MethodIdentifier}' on instance '{DotNetObjectId}' with callback id '{CallId}'.");

                _beginInvokeDotNetStaticFailed = LoggerMessage.Define <string, string, string>(
                    LogLevel.Debug,
                    EventIds.BeginInvokeDotNetFailed,
                    "Failed to invoke static method with identifier '{MethodIdentifier}' on assembly '{Assembly}' with callback id '{CallId}'.");

                _beginInvokeDotNetInstanceFailed = LoggerMessage.Define <string, long, string>(
                    LogLevel.Debug,
                    EventIds.BeginInvokeDotNetFailed,
                    "Failed to invoke instance method '{MethodIdentifier}' on instance '{DotNetObjectId}' with callback id '{CallId}'.");

                _endInvokeDispatchException = LoggerMessage.Define(
                    LogLevel.Debug,
                    EventIds.EndInvokeDispatchException,
                    "There was an error invoking 'Microsoft.JSInterop.DotNetDispatcher.EndInvoke'.");

                _endInvokeJSFailed = LoggerMessage.Define <long, string>(
                    LogLevel.Debug,
                    EventIds.EndInvokeJSFailed,
                    "The JS interop call with callback id '{AsyncCall}' failed with error '{Error}'.");

                _endInvokeJSSucceeded = LoggerMessage.Define <long>(
                    LogLevel.Debug,
                    EventIds.EndInvokeJSSucceeded,
                    "The JS interop call with callback id '{AsyncCall}' succeeded.");

                _dispatchEventFailedToParseEventData = LoggerMessage.Define(
                    LogLevel.Debug,
                    EventIds.DispatchEventFailedToParseEventData,
                    "Failed to parse the event data when trying to dispatch an event.");

                _dispatchEventFailedToDispatchEvent = LoggerMessage.Define <string>(
                    LogLevel.Debug,
                    EventIds.DispatchEventFailedToDispatchEvent,
                    "There was an error dispatching the event '{EventHandlerId}' to the application.");

                _locationChange = LoggerMessage.Define <string, CircuitId>(
                    LogLevel.Debug,
                    EventIds.LocationChange,
                    "Location changing to {URI} in circuit '{CircuitId}'.");

                _locationChangeSucceeded = LoggerMessage.Define <string, CircuitId>(
                    LogLevel.Debug,
                    EventIds.LocationChangeSucceeded,
                    "Location change to '{URI}' in circuit '{CircuitId}' succeeded.");

                _locationChangeFailed = LoggerMessage.Define <string, CircuitId>(
                    LogLevel.Debug,
                    EventIds.LocationChangeFailed,
                    "Location change to '{URI}' in circuit '{CircuitId}' failed.");

                _locationChangeFailedInCircuit = LoggerMessage.Define <string, CircuitId>(
                    LogLevel.Error,
                    EventIds.LocationChangeFailed,
                    "Location change to '{URI}' in circuit '{CircuitId}' failed.");

                _onRenderCompletedFailed = LoggerMessage.Define <long, CircuitId>(
                    LogLevel.Debug,
                    EventIds.OnRenderCompletedFailed,
                    "Failed to complete render batch '{RenderId}' in circuit host '{CircuitId}'.");
            }
Exemplo n.º 11
0
 static LoggerExtensions()
 {
     _CLT00001_Warning_Property_propertyName_ignored = LoggerMessage.Define <object>(
         LogLevel.Warning,
         new EventId(1, nameof(Logs.CLT00001)),
         Logs.CLT00001);
     _CLT00002_Error_Error_sending_log_in_ClickHouse_content = LoggerMessage.Define <object>(
         LogLevel.Error,
         new EventId(2, nameof(Logs.CLT00002)),
         Logs.CLT00002);
     _CLT00003_Information_Created_Output_plugin_Type_pluginName_SystemName_systemName = LoggerMessage.Define <object, object>(
         LogLevel.Information,
         new EventId(3, nameof(Logs.CLT00003)),
         Logs.CLT00003);
     _SLT00001_Trace_LogController_created = LoggerMessage.Define(
         LogLevel.Trace,
         new EventId(1, nameof(Logs.SLT00001)),
         Logs.SLT00001);
     _SLT00002_Debug_LogController_End = LoggerMessage.Define(
         LogLevel.Debug,
         new EventId(2, nameof(Logs.SLT00002)),
         Logs.SLT00002);
     _SLT00003_Debug_LogController_Start = LoggerMessage.Define(
         LogLevel.Debug,
         new EventId(3, nameof(Logs.SLT00003)),
         Logs.SLT00003);
     _SLT00004_Trace_Method_Metrics_metricData = LoggerMessage.Define <object>(
         LogLevel.Trace,
         new EventId(4, nameof(Logs.SLT00004)),
         Logs.SLT00004);
     _SLT00005_Debug_Save_log_from_system_system = LoggerMessage.Define <object>(
         LogLevel.Debug,
         new EventId(5, nameof(Logs.SLT00005)),
         Logs.SLT00005);
     _SLT00006_Error_Not_save_log_for_system_CLS = LoggerMessage.Define <object>(
         LogLevel.Error,
         new EventId(6, nameof(Logs.SLT00006)),
         Logs.SLT00006);
     _SLT00007_Error_Invalid_input_line_line = LoggerMessage.Define <object>(
         LogLevel.Error,
         new EventId(7, nameof(Logs.SLT00007)),
         Logs.SLT00007);
     _SLT00008_Debug_LogMetrics_Start = LoggerMessage.Define(
         LogLevel.Debug,
         new EventId(8, nameof(Logs.SLT00008)),
         Logs.SLT00008);
     _SLT00009_Debug_LogMetrics_End = LoggerMessage.Define(
         LogLevel.Debug,
         new EventId(9, nameof(Logs.SLT00009)),
         Logs.SLT00009);
     _SLT00010_Trace_PluginFactory_Start = LoggerMessage.Define(
         LogLevel.Trace,
         new EventId(10, nameof(Logs.SLT00010)),
         Logs.SLT00010);
     _SLT00011_Debug_PluginFactory_End = LoggerMessage.Define(
         LogLevel.Debug,
         new EventId(11, nameof(Logs.SLT00011)),
         Logs.SLT00011);
     _SLT00012_Debug_PluginFactory = LoggerMessage.Define(
         LogLevel.Debug,
         new EventId(12, nameof(Logs.SLT00012)),
         Logs.SLT00012);
     _SLT00013_Debug_Create_Output_pluginType_plugin_SystemName_systemName = LoggerMessage.Define <object, object>(
         LogLevel.Debug,
         new EventId(13, nameof(Logs.SLT00013)),
         Logs.SLT00013);
     _SLT00014_Error_Plugin_not_created = LoggerMessage.Define(
         LogLevel.Error,
         new EventId(14, nameof(Logs.SLT00014)),
         Logs.SLT00014);
     _SLT00019_Trace_Main_buffer_settings_config_bufferSettingsConfig = LoggerMessage.Define <object>(
         LogLevel.Trace,
         new EventId(19, nameof(Logs.SLT00019)),
         Logs.SLT00019);
     _SLT00020_Debug_Child_settings_empty_Parent_config_is_applied = LoggerMessage.Define(
         LogLevel.Debug,
         new EventId(20, nameof(Logs.SLT00020)),
         Logs.SLT00020);
     _SLT00021_Debug_Child_and_parent_settings_merged = LoggerMessage.Define(
         LogLevel.Debug,
         new EventId(21, nameof(Logs.SLT00021)),
         Logs.SLT00021);
     _SLT00022_Trace_Plugin_output_config_clickHousePluginConfig = LoggerMessage.Define <object>(
         LogLevel.Trace,
         new EventId(22, nameof(Logs.SLT00022)),
         Logs.SLT00022);
     _SLT00023_Trace_Plugin_output_config_forwardOutputConfig = LoggerMessage.Define <object>(
         LogLevel.Trace,
         new EventId(23, nameof(Logs.SLT00023)),
         Logs.SLT00023);
     _SLT00024_Debug_Child_settings_empty_Parent_config_is_applied = LoggerMessage.Define(
         LogLevel.Debug,
         new EventId(24, nameof(Logs.SLT00024)),
         Logs.SLT00024);
     _SLT00025_Debug_Child_and_parent_settings_merged = LoggerMessage.Define(
         LogLevel.Debug,
         new EventId(25, nameof(Logs.SLT00025)),
         Logs.SLT00025);
 }
Exemplo n.º 12
0
 static LoggerExtensions()
 {
     _programStarting = LoggerMessage.Define <DateTimeOffset>(LogLevel.Information, 1, "Starting at '{StartTime}'");
     _programStopping = LoggerMessage.Define <DateTimeOffset>(LogLevel.Information, 2, "Stopping at '{StopTime}'");
 }
        static MvcViewFeaturesLoggerExtensions()
        {
            _viewComponentExecuting = LoggerMessage.Define <string, string[]>(
                LogLevel.Debug,
                new EventId(1, "ViewComponentExecuting"),
                "Executing view component {ViewComponentName} with arguments ({Arguments}).");

            _viewComponentExecuted = LoggerMessage.Define <string, double, string>(
                LogLevel.Debug,
                new EventId(2, "ViewComponentExecuted"),
                "Executed view component {ViewComponentName} in {ElapsedMilliseconds}ms and returned " +
                "{ViewComponentResult}");

            _partialViewResultExecuting = LoggerMessage.Define <string>(
                LogLevel.Information,
                new EventId(1, "PartialViewResultExecuting"),
                "Executing PartialViewResult, running view {PartialViewName}.");

            _partialViewFound = LoggerMessage.Define <string, double>(
                LogLevel.Debug,
                new EventId(2, "PartialViewFound"),
                "The partial view path '{PartialViewFilePath}' was found in {ElapsedMilliseconds}ms.");

            _partialViewNotFound = LoggerMessage.Define <string, IEnumerable <string> >(
                LogLevel.Error,
                new EventId(3, "PartialViewNotFound"),
                "The partial view '{PartialViewName}' was not found. Searched locations: {SearchedViewLocations}");

            _partialViewResultExecuted = LoggerMessage.Define <string, double>(
                LogLevel.Information,
                new EventId(4, "PartialViewResultExecuted"),
                "Executed PartialViewResult - view {PartialViewName} executed in {ElapsedMilliseconds}ms.");

            _antiforgeryTokenInvalid = LoggerMessage.Define <string>(
                LogLevel.Information,
                new EventId(1, "AntiforgeryTokenInvalid"),
                "Antiforgery token validation failed. {Message}");

            _viewComponentResultExecuting = LoggerMessage.Define <string>(
                LogLevel.Information,
                new EventId(1, "ViewComponentResultExecuting"),
                "Executing ViewComponentResult, running {ViewComponentName}.");

            _viewResultExecuting = LoggerMessage.Define <string>(
                LogLevel.Information,
                new EventId(1, "ViewResultExecuting"),
                "Executing ViewResult, running view {ViewName}.");

            _viewFound = LoggerMessage.Define <string, double>(
                LogLevel.Debug,
                new EventId(2, "ViewFound"),
                "The view path '{ViewFilePath}' was found in {ElapsedMilliseconds}ms.");

            _viewNotFound = LoggerMessage.Define <string, IEnumerable <string> >(
                LogLevel.Error,
                new EventId(3, "ViewNotFound"),
                "The view '{ViewName}' was not found. Searched locations: {SearchedViewLocations}");

            _viewResultExecuted = LoggerMessage.Define <string, double>(
                LogLevel.Information,
                new EventId(4, "ViewResultExecuted"),
                "Executed ViewResult - view {ViewName} executed in {ElapsedMilliseconds}ms.");

            _tempDataCookieNotFound = LoggerMessage.Define <string>(
                LogLevel.Debug,
                new EventId(1, "TempDataCookieNotFound"),
                "The temp data cookie {CookieName} was not found.");

            _tempDataCookieLoadSuccess = LoggerMessage.Define <string>(
                LogLevel.Debug,
                new EventId(2, "TempDataCookieLoadSuccess"),
                "The temp data cookie {CookieName} was used to successfully load temp data.");

            _tempDataCookieLoadFailure = LoggerMessage.Define <string>(
                LogLevel.Warning,
                new EventId(3, "TempDataCookieLoadFailure"),
                "The temp data cookie {CookieName} could not be loaded.");

            _notMostEffectiveFilter = LoggerMessage.Define <Type>(
                LogLevel.Trace,
                new EventId(1, "NotMostEffectiveFilter"),
                "Skipping the execution of current filter as its not the most effective filter implementing the policy {FilterPolicy}.");
        }
Exemplo n.º 14
0
        static PageLoggerExtensions()
        {
            // These numbers start at 101 intentionally to avoid conflict with the IDs used by ResourceInvoker.

            _pageModelFactoryExecuting = LoggerMessage.Define <string, string>(
                LogLevel.Debug,
                new EventId(101, "ExecutingModelFactory"),
                "Executing page model factory for page {Page} ({AssemblyName})",
                skipEnabledCheck: true);

            _pageModelFactoryExecuted = LoggerMessage.Define <string, string>(
                LogLevel.Debug,
                new EventId(102, "ExecutedModelFactory"),
                "Executed page model factory for page {Page} ({AssemblyName})",
                skipEnabledCheck: true);

            _pageFactoryExecuting = LoggerMessage.Define <string, string>(
                LogLevel.Debug,
                new EventId(101, "ExecutingPageFactory"),
                "Executing page factory for page {Page} ({AssemblyName})",
                skipEnabledCheck: true);

            _pageFactoryExecuted = LoggerMessage.Define <string, string>(
                LogLevel.Debug,
                new EventId(102, "ExecutedPageFactory"),
                "Executed page factory for page {Page} ({AssemblyName})",
                skipEnabledCheck: true);

            _handlerMethodExecuting = LoggerMessage.Define <string, ModelValidationState>(
                LogLevel.Information,
                new EventId(101, "ExecutingHandlerMethod"),
                "Executing handler method {HandlerName} - ModelState is {ValidationState}",
                skipEnabledCheck: true);

            _handlerMethodExecutingWithArguments = LoggerMessage.Define <string, string[]>(
                LogLevel.Trace,
                new EventId(103, "HandlerMethodExecutingWithArguments"),
                "Executing handler method {HandlerName} with arguments ({Arguments})",
                skipEnabledCheck: true);

            _handlerMethodExecuted = LoggerMessage.Define <string, string>(
                LogLevel.Information,
                new EventId(102, "ExecutedHandlerMethod"),
                "Executed handler method {HandlerName}, returned result {ActionResult}.",
                skipEnabledCheck: true);

            _implicitHandlerMethodExecuting = LoggerMessage.Define <ModelValidationState>(
                LogLevel.Information,
                new EventId(103, "ExecutingImplicitHandlerMethod"),
                "Executing an implicit handler method - ModelState is {ValidationState}",
                skipEnabledCheck: true);

            _implicitHandlerMethodExecuted = LoggerMessage.Define <string>(
                LogLevel.Information,
                new EventId(104, "ExecutedImplicitHandlerMethod"),
                "Executed an implicit handler method, returned result {ActionResult}.",
                skipEnabledCheck: true);

            _pageFilterShortCircuit = LoggerMessage.Define <object>(
                LogLevel.Debug,
                new EventId(3, "PageFilterShortCircuited"),
                "Request was short circuited at page filter '{PageFilter}'.");

            _notMostEffectiveFilter = LoggerMessage.Define <Type>(
                LogLevel.Debug,
                new EventId(1, "NotMostEffectiveFilter"),
                "Skipping the execution of current filter as its not the most effective filter implementing the policy {FilterPolicy}.");

            _beforeExecutingMethodOnFilter = LoggerMessage.Define <string, string, string>(
                LogLevel.Trace,
                new EventId(1, "BeforeExecutingMethodOnFilter"),
                "{FilterType}: Before executing {Method} on filter {Filter}.");

            _afterExecutingMethodOnFilter = LoggerMessage.Define <string, string, string>(
                LogLevel.Trace,
                new EventId(2, "AfterExecutingMethodOnFilter"),
                "{FilterType}: After executing {Method} on filter {Filter}.");
        }
Exemplo n.º 15
0
        static MvcCoreLoggerExtensions()
        {
            _actionExecuting = LoggerMessage.Define <string>(
                LogLevel.Debug,
                1,
                "Executing action {ActionName}");

            _actionExecuted = LoggerMessage.Define <string, double>(
                LogLevel.Information,
                2,
                "Executed action {ActionName} in {ElapsedMilliseconds}ms");

            _challengeResultExecuting = LoggerMessage.Define <string[]>(
                LogLevel.Information,
                1,
                "Executing ChallengeResult with authentication schemes ({Schemes}).");

            _contentResultExecuting = LoggerMessage.Define <string>(
                LogLevel.Information,
                1,
                "Executing ContentResult with HTTP Response ContentType of {ContentType}");

            _actionMethodExecuting = LoggerMessage.Define <string, string[], ModelValidationState>(
                LogLevel.Information,
                1,
                "Executing action method {ActionName} with arguments ({Arguments}) - ModelState is {ValidationState}");

            _actionMethodExecuted = LoggerMessage.Define <string, string>(
                LogLevel.Debug,
                2,
                "Executed action method {ActionName}, returned result {ActionResult}.");

            _ambiguousActions = LoggerMessage.Define <string>(
                LogLevel.Error,
                1,
                "Request matched multiple actions resulting in ambiguity. Matching actions: {AmbiguousActions}");

            _constraintMismatch = LoggerMessage.Define <string, string, IActionConstraint>(
                LogLevel.Debug,
                2,
                "Action '{ActionName}' with id '{ActionId}' did not match the constraint '{ActionConstraint}'");

            _fileResultExecuting = LoggerMessage.Define <string>(
                LogLevel.Information,
                1,
                "Executing FileResult, sending file as {FileDownloadName}");

            _authorizationFailure = LoggerMessage.Define <object>(
                LogLevel.Information,
                3,
                "Authorization failed for the request at filter '{AuthorizationFilter}'.");

            _resourceFilterShortCircuit = LoggerMessage.Define <object>(
                LogLevel.Debug,
                4,
                "Request was short circuited at resource filter '{ResourceFilter}'.");

            _resultFilterShortCircuit = LoggerMessage.Define <object>(
                LogLevel.Debug,
                5,
                "Request was short circuited at result filter '{ResultFilter}'.");

            _actionFilterShortCircuit = LoggerMessage.Define <object>(
                LogLevel.Debug,
                3,
                "Request was short circuited at action filter '{ActionFilter}'.");

            _exceptionFilterShortCircuit = LoggerMessage.Define <object>(
                LogLevel.Debug,
                4,
                "Request was short circuited at exception filter '{ExceptionFilter}'.");

            _forbidResultExecuting = LoggerMessage.Define <string[]>(
                LogLevel.Information,
                eventId: 1,
                formatString: $"Executing {nameof(ForbidResult)} with authentication schemes ({{Schemes}}).");

            _signInResultExecuting = LoggerMessage.Define <string, ClaimsPrincipal>(
                LogLevel.Information,
                eventId: 1,
                formatString: $"Executing {nameof(SignInResult)} with authentication scheme ({{Scheme}}) and the following principal: {{Principal}}.");

            _signOutResultExecuting = LoggerMessage.Define <string[]>(
                LogLevel.Information,
                eventId: 1,
                formatString: $"Executing {nameof(SignOutResult)} with authentication schemes ({{Schemes}}).");

            _httpStatusCodeResultExecuting = LoggerMessage.Define <int>(
                LogLevel.Information,
                1,
                "Executing HttpStatusCodeResult, setting HTTP status code {StatusCode}");

            _localRedirectResultExecuting = LoggerMessage.Define <string>(
                LogLevel.Information,
                1,
                "Executing LocalRedirectResult, redirecting to {Destination}.");

            _noFormatter = LoggerMessage.Define <string>(
                LogLevel.Warning,
                1,
                "No output formatter was found for content type '{ContentType}' to write the response.");

            _objectResultExecuting = LoggerMessage.Define <string>(
                LogLevel.Information,
                1,
                "Executing ObjectResult, writing value of type '{Type}'.");

            _formatterSelected = LoggerMessage.Define <IOutputFormatter, string>(
                LogLevel.Debug,
                2,
                "Selected output formatter '{OutputFormatter}' and content type '{ContentType}' to write the response.");

            _skippedContentNegotiation = LoggerMessage.Define <string>(
                LogLevel.Debug,
                3,
                "Skipped content negotiation as content type '{ContentType}' is explicitly set for the response.");

            _noAcceptForNegotiation = LoggerMessage.Define(
                LogLevel.Debug,
                4,
                "No information found on request to perform content negotiation.");

            _noFormatterFromNegotiation = LoggerMessage.Define <IEnumerable <MediaTypeSegmentWithQuality> >(
                LogLevel.Debug,
                5,
                "Could not find an output formatter based on content negotiation. Accepted types were ({AcceptTypes})");

            _inputFormatterSelected = LoggerMessage.Define <IInputFormatter, string>(
                LogLevel.Debug,
                1,
                "Selected input formatter '{InputFormatter}' for content type '{ContentType}'.");

            _inputFormatterRejected = LoggerMessage.Define <IInputFormatter, string>(
                LogLevel.Debug,
                2,
                "Rejected input formatter '{InputFormatter}' for content type '{ContentType}'.");

            _noInputFormatterSelected = LoggerMessage.Define <string>(
                LogLevel.Debug,
                3,
                "No input formatter was found to support the content type '{ContentType}' for use with the [FromBody] attribute.");

            _removeFromBodyAttribute = LoggerMessage.Define <string, string>(
                LogLevel.Debug,
                4,
                "To use model binding, remove the [FromBody] attribute from the property or parameter named '{ModelName}' with model type '{ModelType}'.");

            _redirectResultExecuting = LoggerMessage.Define <string>(
                LogLevel.Information,
                1,
                "Executing RedirectResult, redirecting to {Destination}.");

            _redirectToActionResultExecuting = LoggerMessage.Define <string>(
                LogLevel.Information,
                1,
                "Executing RedirectResult, redirecting to {Destination}.");

            _redirectToRouteResultExecuting = LoggerMessage.Define <string, string>(
                LogLevel.Information,
                1,
                "Executing RedirectToRouteResult, redirecting to {Destination} from route {RouteName}.");

            _redirectToPageResultExecuting = LoggerMessage.Define <string>(
                LogLevel.Information,
                1,
                "Executing RedirectToPageResult, redirecting to {Page}.");

            _noActionsMatched = LoggerMessage.Define <string[]>(
                LogLevel.Debug,
                3,
                "No actions matched the current request. Route values: {RouteValues}");

            _featureNotFound = LoggerMessage.Define(
                LogLevel.Warning,
                1,
                "A request body size limit could not be applied. This server does not support the IHttpRequestBodySizeFeature.");

            _featureIsReadOnly = LoggerMessage.Define(
                LogLevel.Warning,
                2,
                "A request body size limit could not be applied. The IHttpRequestBodySizeFeature for the server is read-only.");

            _maxRequestBodySizeSet = LoggerMessage.Define <string>(
                LogLevel.Debug,
                3,
                "The maximum request body size has been set to {RequestSize}.");

            _requestBodySizeLimitDisabled = LoggerMessage.Define(
                LogLevel.Debug,
                3,
                "The request body size limit has been disabled.");

            _cannotApplyRequestFormLimits = LoggerMessage.Define(
                LogLevel.Warning,
                1,
                "Unable to apply configured form options since the request form has already been read.");

            _appliedRequestFormLimits = LoggerMessage.Define(
                LogLevel.Debug,
                2,
                "Applied the configured form options on the current request.");

            _modelStateInvalidFilterExecuting = LoggerMessage.Define(
                LogLevel.Debug,
                1,
                "The request has model state errors, returning an error response.");

            _inferredParameterSource = LoggerMessage.Define <MethodInfo, string, string>(
                LogLevel.Debug,
                1,
                "Inferred binding source for '{ParameterName}` on `{ActionName}` as {BindingSource}.");

            _unableToInferParameterSources = LoggerMessage.Define <MethodInfo>(
                LogLevel.Warning,
                2,
                "Unable to unambiguously infer binding sources for parameters on '{ActionName}'. More than one parameter may be inferred to bound from body.");
        }
Exemplo n.º 16
0
 static LoggingExtensions()
 {
     _remoteAuthenticationError = LoggerMessage.Define <string>(
         eventId: 1004,
         logLevel: LogLevel.Information,
         formatString: "Error from RemoteAuthenentication: {ErrorMessage}.");
     _signInHandled = LoggerMessage.Define(
         eventId: 1005,
         logLevel: LogLevel.Information,
         formatString: "The SignIn event returned Handled");
     _signInSkipped = LoggerMessage.Define(
         eventId: 1006,
         logLevel: LogLevel.Information,
         formatString: "The SignIn event returned Skipped");
     // Final
     _redirectToIdentityProviderForSignOutHandledResponse = LoggerMessage.Define(
         eventId: 1,
         logLevel: LogLevel.Debug,
         formatString: "RedirectToIdentityProviderForSignOut.HandledResponse");
     _invalidLogoutQueryStringRedirectUrl = LoggerMessage.Define <string>(
         eventId: 3,
         logLevel: LogLevel.Warning,
         formatString: "The query string for Logout is not a well-formed URI. Redirect URI: '{RedirectUrl}'.");
     _enteringOpenIdAuthenticationHandlerHandleUnauthorizedAsync = LoggerMessage.Define <string>(
         eventId: 4,
         logLevel: LogLevel.Trace,
         formatString: "Entering {OpenIdConnectHandlerType}'s HandleUnauthorizedAsync.");
     _enteringOpenIdAuthenticationHandlerHandleSignOutAsync = LoggerMessage.Define <string>(
         eventId: 14,
         logLevel: LogLevel.Trace,
         formatString: "Entering {OpenIdConnectHandlerType}'s HandleSignOutAsync.");
     _postAuthenticationLocalRedirect = LoggerMessage.Define <string>(
         eventId: 5,
         logLevel: LogLevel.Trace,
         formatString: "Using properties.RedirectUri for 'local redirect' post authentication: '{RedirectUri}'.");
     _redirectToIdentityProviderHandledResponse = LoggerMessage.Define(
         eventId: 6,
         logLevel: LogLevel.Debug,
         formatString: "RedirectToIdentityProvider.HandledResponse");
     _invalidAuthenticationRequestUrl = LoggerMessage.Define <string>(
         eventId: 8,
         logLevel: LogLevel.Warning,
         formatString: "The redirect URI is not well-formed. The URI is: '{AuthenticationRequestUrl}'.");
     _enteringOpenIdAuthenticationHandlerHandleRemoteAuthenticateAsync = LoggerMessage.Define <string>(
         eventId: 9,
         logLevel: LogLevel.Trace,
         formatString: "Entering {OpenIdConnectHandlerType}'s HandleRemoteAuthenticateAsync.");
     _nullOrEmptyAuthorizationResponseState = LoggerMessage.Define(
         eventId: 10,
         logLevel: LogLevel.Debug,
         formatString: "message.State is null or empty.");
     _unableToReadAuthorizationResponseState = LoggerMessage.Define(
         eventId: 11,
         logLevel: LogLevel.Debug,
         formatString: "Unable to read the message.State.");
     _responseError = LoggerMessage.Define <string, string, string>(
         eventId: 12,
         logLevel: LogLevel.Error,
         formatString: "Message contains error: '{Error}', error_description: '{ErrorDescription}', error_uri: '{ErrorUri}'.");
     _responseErrorWithStatusCode = LoggerMessage.Define <string, string, string, int>(
         eventId: 49,
         logLevel: LogLevel.Error,
         formatString: "Message contains error: '{Error}', error_description: '{ErrorDescription}', error_uri: '{ErrorUri}', status code '{StatusCode}'.");
     _updatingConfiguration = LoggerMessage.Define(
         eventId: 13,
         logLevel: LogLevel.Debug,
         formatString: "Updating configuration");
     _tokenValidatedHandledResponse = LoggerMessage.Define(
         eventId: 15,
         logLevel: LogLevel.Debug,
         formatString: "TokenValidated.HandledResponse");
     _tokenValidatedSkipped = LoggerMessage.Define(
         eventId: 16,
         logLevel: LogLevel.Debug,
         formatString: "TokenValidated.Skipped");
     _exceptionProcessingMessage = LoggerMessage.Define(
         eventId: 17,
         logLevel: LogLevel.Error,
         formatString: "Exception occurred while processing message.");
     _configurationManagerRequestRefreshCalled = LoggerMessage.Define(
         eventId: 18,
         logLevel: LogLevel.Debug,
         formatString: "Exception of type 'SecurityTokenSignatureKeyNotFoundException' thrown, Options.ConfigurationManager.RequestRefresh() called.");
     _redeemingCodeForTokens = LoggerMessage.Define(
         eventId: 19,
         logLevel: LogLevel.Debug,
         formatString: "Redeeming code for tokens.");
     _retrievingClaims = LoggerMessage.Define(
         eventId: 20,
         logLevel: LogLevel.Trace,
         formatString: "Retrieving claims from the user info endpoint.");
     _receivedIdToken = LoggerMessage.Define(
         eventId: 21,
         logLevel: LogLevel.Debug,
         formatString: "Received 'id_token'");
     _userInfoEndpointNotSet = LoggerMessage.Define(
         eventId: 22,
         logLevel: LogLevel.Debug,
         formatString: "UserInfoEndpoint is not set. Claims cannot be retrieved.");
     _unableToProtectNonceCookie = LoggerMessage.Define(
         eventId: 23,
         logLevel: LogLevel.Warning,
         formatString: "Failed to un-protect the nonce cookie.");
     _messageReceived = LoggerMessage.Define <string>(
         eventId: 24,
         logLevel: LogLevel.Trace,
         formatString: "MessageReceived: '{RedirectUrl}'.");
     _messageReceivedContextHandledResponse = LoggerMessage.Define(
         eventId: 25,
         logLevel: LogLevel.Debug,
         formatString: "MessageReceivedContext.HandledResponse");
     _messageReceivedContextSkipped = LoggerMessage.Define(
         eventId: 26,
         logLevel: LogLevel.Debug,
         formatString: "MessageReceivedContext.Skipped");
     _authorizationCodeReceived = LoggerMessage.Define(
         eventId: 27,
         logLevel: LogLevel.Trace,
         formatString: "Authorization code received.");
     _authorizationCodeReceivedContextHandledResponse = LoggerMessage.Define(
         eventId: 28,
         logLevel: LogLevel.Debug,
         formatString: "AuthorizationCodeReceivedContext.HandledResponse");
     _authorizationCodeReceivedContextSkipped = LoggerMessage.Define(
         eventId: 29,
         logLevel: LogLevel.Debug,
         formatString: "AuthorizationCodeReceivedContext.Skipped");
     _tokenResponseReceived = LoggerMessage.Define(
         eventId: 30,
         logLevel: LogLevel.Trace,
         formatString: "Token response received.");
     _tokenResponseReceivedHandledResponse = LoggerMessage.Define(
         eventId: 31,
         logLevel: LogLevel.Debug,
         formatString: "TokenResponseReceived.HandledResponse");
     _tokenResponseReceivedSkipped = LoggerMessage.Define(
         eventId: 32,
         logLevel: LogLevel.Debug,
         formatString: "TokenResponseReceived.Skipped");
     _postSignOutRedirect = LoggerMessage.Define <string>(
         eventId: 33,
         logLevel: LogLevel.Trace,
         formatString: "Using properties.RedirectUri for redirect post authentication: '{RedirectUri}'.");
     _userInformationReceived = LoggerMessage.Define <string>(
         eventId: 35,
         logLevel: LogLevel.Trace,
         formatString: "User information received: {User}");
     _userInformationReceivedHandledResponse = LoggerMessage.Define(
         eventId: 36,
         logLevel: LogLevel.Debug,
         formatString: "The UserInformationReceived event returned Handled.");
     _userInformationReceivedSkipped = LoggerMessage.Define(
         eventId: 37,
         logLevel: LogLevel.Debug,
         formatString: "The UserInformationReceived event returned Skipped.");
     _authenticationFailedContextHandledResponse = LoggerMessage.Define(
         eventId: 38,
         logLevel: LogLevel.Debug,
         formatString: "AuthenticationFailedContext.HandledResponse");
     _authenticationFailedContextSkipped = LoggerMessage.Define(
         eventId: 39,
         logLevel: LogLevel.Debug,
         formatString: "AuthenticationFailedContext.Skipped");
     _invalidSecurityTokenType = LoggerMessage.Define <string>(
         eventId: 40,
         logLevel: LogLevel.Error,
         formatString: "The Validated Security Token must be of type JwtSecurityToken, but instead its type is: '{SecurityTokenType}'");
     _unableToValidateIdToken = LoggerMessage.Define <string>(
         eventId: 41,
         logLevel: LogLevel.Error,
         formatString: "Unable to validate the 'id_token', no suitable ISecurityTokenValidator was found for: '{IdToken}'.");
     _accessTokenNotAvailable = LoggerMessage.Define(
         eventId: 42,
         logLevel: LogLevel.Debug,
         formatString: "The access_token is not available. Claims cannot be retrieved.");
     _unableToReadIdToken = LoggerMessage.Define <string>(
         eventId: 43,
         logLevel: LogLevel.Error,
         formatString: "Unable to read the 'id_token', no suitable ISecurityTokenValidator was found for: '{IdToken}'.");
     _remoteSignOutHandledResponse = LoggerMessage.Define(
         eventId: 44,
         logLevel: LogLevel.Debug,
         formatString: "RemoteSignOutContext.HandledResponse");
     _remoteSignOutSkipped = LoggerMessage.Define(
         eventId: 45,
         logLevel: LogLevel.Debug,
         formatString: "RemoteSignOutContext.Skipped");
     _remoteSignOut = LoggerMessage.Define(
         eventId: 46,
         logLevel: LogLevel.Information,
         formatString: "Remote signout request processed.");
     _remoteSignOutSessionIdMissing = LoggerMessage.Define(
         eventId: 47,
         logLevel: LogLevel.Error,
         formatString: "The remote signout request was ignored because the 'sid' parameter " +
         "was missing, which may indicate an unsolicited logout.");
     _remoteSignOutSessionIdInvalid = LoggerMessage.Define(
         eventId: 48,
         logLevel: LogLevel.Error,
         formatString: "The remote signout request was ignored because the 'sid' parameter didn't match " +
         "the expected value, which may indicate an unsolicited logout.");
     _signOut = LoggerMessage.Define <string>(
         eventId: 49,
         logLevel: LogLevel.Information,
         formatString: "AuthenticationScheme: {AuthenticationScheme} signed out.");
     _signoutCallbackRedirectHandledResponse = LoggerMessage.Define(
         eventId: 50,
         logLevel: LogLevel.Debug,
         formatString: "RedirectToSignedOutRedirectUri.HandledResponse");
     _signoutCallbackRedirectSkipped = LoggerMessage.Define(
         eventId: 51,
         logLevel: LogLevel.Debug,
         formatString: "RedirectToSignedOutRedirectUri.Skipped");
 }
Exemplo n.º 17
0
 private void WriteBizErrorLogger(Exception ex)
 {
     LoggerMessage.Define(LogLevel.Error,
                          new EventId(7, "服务异常"),
                          $"工作流发生业务异常{Environment.NewLine}{ex.Message}{Environment.NewLine}{ex.StackTrace}")(logger, ex);
 }
Exemplo n.º 18
0
 static ScopeWithOneParameter()
 {
     ScopeDelegate = LoggerMessage.DefineScope <string>(NamedStringFormat);
 }
Exemplo n.º 19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QueryResultTypeGenerator"/> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <exception cref="ArgumentNullException">logger</exception>
 public QueryResultTypeGenerator(ILogger <QueryResultTypeGenerator> logger)
 {
     _logger = logger ?? throw new ArgumentNullException(nameof(logger));
     _log4GenerateQueryResultType = LoggerMessage.Define <DateTimeOffset, string>(LogLevel.Trace, 0, "[{0}Dynamically generate query result type. Source type: {1}]");
 }
Exemplo n.º 20
0
 public override bool SendMessage(LoggerMessage message)
 {
     return(false);
 }
 static LoggerExtensions()
 {
     _logMethodNotSupported = LoggerMessage.Define <string>(
         logLevel: LogLevel.Trace,
         eventId: 1,
         formatString: "{Method} requests are not supported");
     _logFileServed = LoggerMessage.Define <string, string, string>(
         logLevel: LogLevel.Information,
         eventId: 2,
         formatString: "Sending file to {User}. Request path: '{VirtualPath}'. Physical path: '{PhysicalPath}'");
     _logPathMismatch = LoggerMessage.Define <string>(
         logLevel: LogLevel.Trace,
         eventId: 3,
         formatString: "The request path {Path} does not match the path filter");
     _logFileTypeNotSupported = LoggerMessage.Define <string>(
         logLevel: LogLevel.Trace,
         eventId: 4,
         formatString: "The request path {Path} does not match a supported file type");
     _logFileNotFound = LoggerMessage.Define <string>(
         logLevel: LogLevel.Trace,
         eventId: 5,
         formatString: "The request path {Path} does not match an existing file");
     _logPathNotModified = LoggerMessage.Define <string>(
         logLevel: LogLevel.Trace,
         eventId: 6,
         formatString: "The file {Path} was not modified");
     _logPreconditionFailed = LoggerMessage.Define <string>(
         logLevel: LogLevel.Trace,
         eventId: 7,
         formatString: "Precondition for {Path} failed");
     _logHandled = LoggerMessage.Define <int, string>(
         logLevel: LogLevel.Debug,
         eventId: 8,
         formatString: "Handled. Status code: {StatusCode} File: {Path}");
     _logRangeNotSatisfiable = LoggerMessage.Define <string>(
         logLevel: LogLevel.Warning,
         eventId: 9,
         formatString: "Range not satisfiable for {Path}");
     _logSendingFileRange = LoggerMessage.Define <StringValues, string, string>(
         logLevel: LogLevel.Debug,
         eventId: 10,
         formatString: "Sending {Range} of file {Path} to {User}");
     _logCopyingFileRange = LoggerMessage.Define <StringValues, string, string>(
         logLevel: LogLevel.Debug,
         eventId: 11,
         formatString: "Copying {Range} of file {Path} to the response body for {User}");
     _logCopyingBytesToResponse = LoggerMessage.Define <long, string, string, string>(
         logLevel: LogLevel.Debug,
         eventId: 12,
         formatString: "Copying bytes {Start}-{End} of file {Path} to response body for {User}");
     _logWriteCancelled = LoggerMessage.Define(
         logLevel: LogLevel.Debug,
         eventId: 14,
         formatString: "The file transmission was cancelled");
     _logNotAuthenticated = LoggerMessage.Define <string, string, string>(
         logLevel: LogLevel.Information,
         eventId: 15,
         formatString:
         "Request from {ip} not authenticated to library {Library} for file {Path}");
     _logNotAuthorized = LoggerMessage.Define <string, string, string>(
         logLevel: LogLevel.Information,
         eventId: 16,
         formatString: "Request for {User} not authorized to library {Library} for file {Path}");
     _logTransportMethod = LoggerMessage.Define <string>(
         logLevel: LogLevel.Trace,
         eventId: 17,
         formatString: "Using {Method} transport method.");
 }
 public static Action <ILogger, Exception?> Define(LogEvent logEvent) =>
 LoggerMessage.Define(logEvent.Level, logEvent.EventId, logEvent.Message);
Exemplo n.º 23
0
 static LogMessages()
 {
     _routePerformance = LoggerMessage.Define <string, string, long>(LogLevel.Information, 0,
                                                                     "{RouteName} {Method} code took {ElapsedMilliseconds}.");
 }
Exemplo n.º 24
0
        static LoggerExtensions()
        {
            attemptingToMatchMethod = LoggerMessage.Define <string>(
                LogLevel.Debug,
                new EventId(1, nameof(AttemptingToMatchMethod)),
                "Attempting to match Rpc request to a method '{Method}'");

            requestMatchedMethod = LoggerMessage.Define(
                LogLevel.Debug,
                new EventId(2, nameof(RequestMatchedMethod)),
                "Request was matched to a method");

            methodsInRoute = LoggerMessage.Define <string>(
                LoggerExtensions.methodsInRouteLevel,
                new EventId(3, nameof(MethodsInRoute)),
                "Methods in route: {MethodsString}");

            invokingBatchRequests = LoggerMessage.Define <int>(
                LogLevel.Debug,
                new EventId(4, nameof(InvokingBatchRequests)),
                "Invoking '{Count}' batch requests");

            batchRequestsComplete = LoggerMessage.Define(
                LogLevel.Debug,
                new EventId(5, nameof(BatchRequestsComplete)),
                "Finished batch requests");

            invokingRequest = LoggerMessage.Define <RpcId>(
                LogLevel.Debug,
                new EventId(6, nameof(InvokingRequest)),
                "Invoking request with id '{Id}'");

            invokeMethod = LoggerMessage.Define <string>(
                LogLevel.Debug,
                new EventId(7, nameof(InvokeMethod)),
                "Attempting to invoke method '{Method}'");

            invokeMethodComplete = LoggerMessage.Define <string>(
                LogLevel.Debug,
                new EventId(8, nameof(InvokeMethodComplete)),
                "Finished invoking method '{Method}'");

            finishedRequest = LoggerMessage.Define <RpcId>(
                LogLevel.Debug,
                new EventId(9, nameof(FinishedRequest)),
                "Finished request with id: {Id}");

            finishedRequestNoId = LoggerMessage.Define(
                LogLevel.Debug,
                new EventId(10, nameof(FinishedRequestNoId)),
                "Finished request with no id. Not returning a response");

            skippingAuth = LoggerMessage.Define(
                LogLevel.Debug,
                new EventId(11, nameof(SkippingAuth)),
                "Skipping authorization. Allow anonymous specified for method.");

            runningAuth = LoggerMessage.Define(
                LogLevel.Debug,
                new EventId(12, nameof(RunningAuth)),
                "Running authorization for method.");

            authSuccessful = LoggerMessage.Define(
                LogLevel.Debug,
                new EventId(13, nameof(AuthSuccessful)),
                "Authorization was successful.");

            authFailed = LoggerMessage.Define(
                LogLevel.Information,
                new EventId(14, nameof(AuthFailed)),
                "Authorization failed.");

            noConfiguredAuth = LoggerMessage.Define(
                LogLevel.Debug,
                new EventId(15, nameof(NoConfiguredAuth)),
                "Skipping authorization. None configured for class or method.");

            parsingRequests = LoggerMessage.Define(
                LogLevel.Debug,
                new EventId(16, nameof(ParsingRequests)),
                "Attempting to parse Rpc request from the json");

            parsedRequests = LoggerMessage.Define <int>(
                LogLevel.Debug,
                new EventId(17, nameof(ParsedRequests)),
                "Successfully parsed {Count} Rpc request(s)");

            processingRequests = LoggerMessage.Define <int>(
                LogLevel.Information,
                new EventId(18, nameof(ProcessingRequests)),
                "Processing {Count} Rpc requests");

            responseFailedWithNoId = LoggerMessage.Define <int, string>(
                LogLevel.Error,
                new EventId(19, nameof(ResponseFailedWithNoId)),
                "Request with no id failed and no response will be sent. Error - Code: {Code}, Message: {Message}");

            noResponses = LoggerMessage.Define(
                LogLevel.Information,
                new EventId(20, nameof(NoResponses)),
                "No rpc responses created.");

            responses = LoggerMessage.Define <int>(
                LogLevel.Information,
                new EventId(21, nameof(Responses)),
                "{Count} rpc response(s) created.");
        }
Exemplo n.º 25
0
            static Log()
            {
                _unhandledExceptionInvokingCircuitHandler = LoggerMessage.Define <Type, string, string>(
                    LogLevel.Error,
                    EventIds.ExceptionInvokingCircuitHandlerMethod,
                    "Unhandled error invoking circuit handler type {handlerType}.{handlerMethod}: {Message}");

                _disposingCircuit = LoggerMessage.Define <string>(
                    LogLevel.Debug,
                    EventIds.DisposingCircuit,
                    "Disposing circuit with identifier {CircuitId}");

                _onCircuitOpened = LoggerMessage.Define <string>(
                    LogLevel.Debug,
                    EventIds.OnCircuitOpened,
                    "Opening circuit with id {CircuitId}.");

                _onConnectionUp = LoggerMessage.Define <string, string>(
                    LogLevel.Debug,
                    EventIds.OnConnectionUp,
                    "Circuit id {CircuitId} connected using connection {ConnectionId}.");

                _onConnectionDown = LoggerMessage.Define <string, string>(
                    LogLevel.Debug,
                    EventIds.OnConnectionDown,
                    "Circuit id {CircuitId} disconnected from connection {ConnectionId}.");

                _onCircuitClosed = LoggerMessage.Define <string>(
                    LogLevel.Debug,
                    EventIds.OnCircuitClosed,
                    "Closing circuit with id {CircuitId}.");

                _beginInvokeDotNetStatic = LoggerMessage.Define <string, string, string>(
                    LogLevel.Debug,
                    EventIds.BeginInvokeDotNet,
                    "Invoking static method with identifier '{MethodIdentifier}' on assembly '{Assembly}' with callback id '{CallId}'");

                _beginInvokeDotNetInstance = LoggerMessage.Define <string, long, string>(
                    LogLevel.Debug,
                    EventIds.BeginInvokeDotNet,
                    "Invoking instance method '{MethodIdentifier}' on instance '{DotNetObjectId}' with callback id '{CallId}'");

                _endInvokeDispatchException = LoggerMessage.Define(
                    LogLevel.Debug,
                    EventIds.EndInvokeDispatchException,
                    "There was an error invoking 'Microsoft.JSInterop.DotNetDispatcher.EndInvoke'.");

                _endInvokeJSFailed = LoggerMessage.Define <long, string>(
                    LogLevel.Debug,
                    EventIds.EndInvokeJSFailed,
                    "The JS interop call with callback id '{AsyncCall}' failed with error '{Error}'.");

                _endInvokeJSSucceeded = LoggerMessage.Define <long>(
                    LogLevel.Debug,
                    EventIds.EndInvokeJSSucceeded,
                    "The JS interop call with callback id '{AsyncCall}' succeeded.");

                _dispatchEventFailedToParseEventDescriptor = LoggerMessage.Define(
                    LogLevel.Debug,
                    EventIds.DispatchEventFailedToParseEventDescriptor,
                    "Failed to parse the event descriptor data when trying to dispatch an event.");

                _dispatchEventFailedToDispatchEvent = LoggerMessage.Define <string>(
                    LogLevel.Debug,
                    EventIds.DispatchEventFailedToDispatchEvent,
                    "There was an error dispatching the event '{EventHandlerId}' to the application.");

                _dispatchEventThroughJSInterop = LoggerMessage.Define(
                    LogLevel.Debug,
                    EventIds.DispatchEventThroughJSInterop,
                    "There was an intent to dispatch a browser event through JS interop.");
            }
Exemplo n.º 26
0
    /// <summary>
    /// Responsible for queuing the log message
    /// </summary>
    /// <param name="tag"></param>
    /// <param name="level"></param>
    /// <param name="level_desc"></param>
    /// <param name="message"></param>
    public void log(string tag, int level, string level_desc, string message)
    {
        if (!alive) return;

        LoggerMessage lm = new LoggerMessage();
        lm.message = message;
        lm.tag = tag;
        lm.level = level;
        lm.level_desc = level_desc;
        lm.time = System.DateTime.Now.ToFileTime();

        q.Enqueue(lm);

        Monitor.Enter(q);
        Monitor.PulseAll(q); //this notifies threads that object has changed
        Monitor.Exit(q);
    }
Exemplo n.º 27
0
 static LoggerExtensions()
 {
     s_requestDebounced = LoggerMessage.Define <string, string>(LogLevel.Information,
                                                                new EventId(1, "RequestDebounced"),
                                                                "Request with trace-id {traceId} and handle {handle} was debounced");
 }
Exemplo n.º 28
0
 public void WriteMessage(LoggerMessage message)
 {
     var logLevel = Convert(message.Severity);
     var logEvent = new log4net.Core.LoggingEvent(null, log.Logger.Repository, log.Logger.Name, logLevel, message.Message, null);
     logEvent.Properties["ThreadId"] = message.ThreadId;
     logEvent.Properties["ThreadName"] = message.ThreadName ?? string.Empty;
     log.Logger.Log(logEvent);
 }
Exemplo n.º 29
0
        static MvcRazorLoggerExtensions()
        {
            _viewCompilerLocatedCompiledView = LoggerMessage.Define <string>(
                LogLevel.Debug,
                3,
                "Initializing Razor view compiler with compiled view: '{ViewName}'.");

            _viewCompilerNoCompiledViewsFound = LoggerMessage.Define(
                LogLevel.Debug,
                4,
                "Initializing Razor view compiler with no compiled views.");

            _viewCompilerLocatedCompiledViewForPath = LoggerMessage.Define <string>(
                LogLevel.Trace,
                5,
                "Located compiled view for view at path '{Path}'.");

            _viewCompilerLocatedCompiledViewForPath = LoggerMessage.Define <string>(
                LogLevel.Trace,
                5,
                "Located compiled view for view at path '{Path}'.");

            _viewCompilerRecompilingCompiledView = LoggerMessage.Define <string>(
                LogLevel.Trace,
                6,
                "Invalidating compiled view for view at path '{Path}'.");

            _viewCompilerCouldNotFindFileToCompileForPath = LoggerMessage.Define <string>(
                LogLevel.Trace,
                7,
                "Could not find a file for view at path '{Path}'.");

            _viewCompilerFoundFileToCompileForPath = LoggerMessage.Define <string>(
                LogLevel.Trace,
                8,
                "Found file at path '{Path}'.");

            _viewCompilerInvalidatingCompiledFile = LoggerMessage.Define <string>(
                LogLevel.Trace,
                9,
                "Invalidating compiled view at path '{Path}' with a file since the checksum did not match.");

            _viewLookupCacheMiss = LoggerMessage.Define <string, string>(
                LogLevel.Debug,
                1,
                "View lookup cache miss for view '{ViewName}' in controller '{ControllerName}'.");

            _viewLookupCacheHit = LoggerMessage.Define <string, string>(
                LogLevel.Debug,
                2,
                "View lookup cache hit for view '{ViewName}' in controller '{ControllerName}'.");

            _precompiledViewFound = LoggerMessage.Define <string>(
                LogLevel.Debug,
                3,
                "Using precompiled view for '{RelativePath}'.");

            _generatedCodeToAssemblyCompilationStart = LoggerMessage.Define <string>(
                LogLevel.Debug,
                1,
                "Compilation of the generated code for the Razor file at '{FilePath}' started.");

            _generatedCodeToAssemblyCompilationEnd = LoggerMessage.Define <string, double>(
                LogLevel.Debug,
                2,
                "Compilation of the generated code for the Razor file at '{FilePath}' completed in {ElapsedMilliseconds}ms.");

            _malformedPageDirective = LoggerMessage.Define <string, string[]>(
                LogLevel.Warning,
                new EventId(104, "MalformedPageDirective"),
                "The page directive at '{FilePath}' is malformed. Please fix the following issues: {Diagnostics}",
                skipEnabledCheck: true);
        }