Skip to content

Commit e409637

Browse files
committed
Fixed a bug were ASP.NET Core 404's were not being logged
1 parent b438581 commit e409637

File tree

6 files changed

+15
-11
lines changed

6 files changed

+15
-11
lines changed

src/Exceptionless/EventBuilder.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public EventBuilder(Event ev, ExceptionlessClient client = null, ContextData plu
1818
public ContextData PluginContextData { get; private set; }
1919

2020
public ExceptionlessClient Client { get; set; }
21-
21+
2222
public Event Target { get; private set; }
2323

2424
/// <summary>
@@ -38,7 +38,7 @@ public EventBuilder SetSource(string source) {
3838
Target.Source = source;
3939
return this;
4040
}
41-
41+
4242
/// <summary>
4343
/// Sets the event reference id.
4444
/// </summary>
@@ -57,7 +57,7 @@ public EventBuilder SetEventReference(string name, string id) {
5757
Target.SetEventReference(name, id);
5858
return this;
5959
}
60-
60+
6161
/// <summary>
6262
/// Sets the event message.
6363
/// </summary>
@@ -132,7 +132,7 @@ public EventBuilder SetProperty(string name, object value, int? maxDepth = null,
132132
public EventBuilder AddObject(object data, string name = null, int? maxDepth = null, ICollection<string> excludedPropertyNames = null, bool ignoreSerializationErrors = false) {
133133
if (data != null)
134134
Target.AddObject(data, name, maxDepth, excludedPropertyNames, ignoreSerializationErrors);
135-
135+
136136
return this;
137137
}
138138

src/Exceptionless/ExceptionlessClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public void SubmitEvent(Event ev, ContextData pluginContextData = null) {
169169
_log.Value.Info(typeof(ExceptionlessClient), "Configuration is disabled. The event will not be submitted.");
170170
return;
171171
}
172-
172+
173173
if (!Configuration.IsValid) {
174174
_log.Value.FormattedInfo(typeof(ExceptionlessClient), "Configuration is invalid: {0}. The event will not be submitted.", String.Join(", ", Configuration.Validate().Messages));
175175
return;

src/Exceptionless/Plugins/Default/010_EventExclusionPlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void Run(EventPluginContext context) {
3535
context.Cancel = true;
3636
return;
3737
}
38-
38+
3939
try {
4040
var exception = context.ContextData.GetException();
4141
while (exception != null) {

src/Platforms/Exceptionless.AspNetCore/ExceptionlessAspNetCorePlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public void Run(EventPluginContext context) {
1515
var serializer = context.Client.Configuration.Resolver.GetJsonSerializer();
1616
if (context.Client.Configuration.IncludePrivateInformation)
1717
AddUser(context, httpContext, serializer);
18-
18+
1919
if (httpContext == null)
2020
return;
2121

src/Platforms/Exceptionless.AspNetCore/ExceptionlessMiddleware.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Threading.Tasks;
33
using Microsoft.AspNetCore.Http;
4-
using Exceptionless;
54
using Exceptionless.Plugins;
65

76
namespace Exceptionless.AspNetCore {
@@ -13,7 +12,7 @@ public ExceptionlessMiddleware(RequestDelegate next, ExceptionlessClient client)
1312
_client = client ?? ExceptionlessClient.Default;
1413
_next = next;
1514
}
16-
15+
1716
public async Task Invoke(HttpContext context) {
1817
try {
1918
await _next(context);
@@ -26,6 +25,11 @@ public async Task Invoke(HttpContext context) {
2625
ex.ToExceptionless(contextData, _client).Submit();
2726
throw;
2827
}
28+
29+
if (context.Response?.StatusCode == 404) {
30+
string path = context.Request.Path.HasValue ? context.Request.Path.Value : "/";
31+
_client.CreateNotFound(path).AddRequestInfo(context).Submit();
32+
}
2933
}
3034
}
3135
}

src/Platforms/Exceptionless.AspNetCore/RequestInfoCollector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ internal static class RequestInfoCollector {
1414
public static RequestInfo Collect(HttpContext context, IEnumerable<string> exclusions) {
1515
if (context == null)
1616
return null;
17-
17+
1818
var info = new RequestInfo {
1919
ClientIpAddress = context.GetClientIpAddress(),
2020
HttpMethod = context.Request.Method,
@@ -89,7 +89,7 @@ private static Dictionary<string, string> ToDictionary(this IRequestCookieCollec
8989

9090
private static Dictionary<string, string> ToDictionary(this IEnumerable<KeyValuePair<string, StringValues>> values, IEnumerable<string> exclusions) {
9191
var d = new Dictionary<string, string>();
92-
92+
9393
foreach (var kvp in values) {
9494
if (String.IsNullOrEmpty(kvp.Key) || kvp.Key.AnyWildcardMatches(_ignoredFormFields) || kvp.Key.AnyWildcardMatches(exclusions))
9595
continue;

0 commit comments

Comments
 (0)