Comments (4)
@tsimbalar Hey sorry about taking a while to get back to you, we had actually moved over to net core so I forgot about looking at this.
I'll see if I can get a PR up for this next week or week after, quite a busy time leading up to holidays :)
from classic.
I think this would also be helpful to report errors in "stacks" on top of ASP.NET like :
- WCF (when hosted in IIS)
- MVC
- Web API
without interfering too much into the hard-coupling IIS / ASP.NET
from classic.
I implemented something locally that seems ok which basically just follows what was already done for the stopwatch in WebRequestLoggingHandler
.
I think it just needs a nicer public api/wrapping with some update to the readme documentation to support the approach.
In my custom ExceptionFilterAttribute
for OnException
and OnExceptionAsync
I added:
HttpContext.Current?.Items.Add(SerilogWebClassic.ErrorKey, context.Exception);
1 line modification to SerilogWeb.Classic.WebRequestLoggingHandler
var error = _application.Server.GetLastError() ?? _application.Context.Items[SerilogWebClassic.ErrorKey] as Exception;
I guess you could switch the order on the above if you want custom exception tracking to have a higher priority.
For the public library version, an extension method could be provided to avoid needing to know about the key details
public static void AddSerilogException(this HttpContext context, Exception ex)
{
context.Items.Add(SerilogWebClassic.ErrorKey, ex);
}
from classic.
Hi @laurencee ,
so sorry for taking so long to react ...
Yes that looks exactly like what I had in mind !
In terms of priority, I think the custom exception should indeed have higher priority (later on, this could be customizable, but that's probably not necessary from the start)
Do you think you could find the time to create a Pull Request for this one ?
from classic.
Related Issues (20)
- Calling cfg.LogAtLevel to set the LogEventLevel seems to disable HTTP request logging? HOT 8
- UserName enricher shows (anonymous) in ApplicationLifecycleModule with Microsoft.AspNet.WebApi.* >= 5.2.5 HOT 5
- Applicationlifecycle module question HOT 7
- Using the EnvironmentUserName if none? HOT 2
- HttpModule stops working when stressed. HOT 6
- Exception with null key in form data HOT 3
- EnableFormDataLogging not logging anything with WebApi HOT 2
- .netStandard v2 version ? HOT 1
- HttpRequestUrlEnricher gives "Request is not available in this context" exception HOT 6
- Special cases when using `FilterKeywords()` with `EnableFormDataLogging()` HOT 5
- ASP .NET Core enrichers? HOT 2
- Add Http Data To All Logging Events HOT 1
- How to troubleshoot the ApplicationLifecycleModule HttpModule is loading and configured properly? HOT 6
- WithUserName Only Working With HttpModule Logging But Doesnt Log During Web Service/API Logs HOT 8
- HttpModule isn't extensible? HOT 2
- SerilogWeb.Classic IIS classic mode incompatibility HOT 1
- Customize HttpRequestEventMessageTemplate HOT 6
- Log CorrelationId with SerilogWeb.Classic's log entries HOT 2
- IIS Web application hang up after multiple requests stuck on "Begin request" HOT 1
- Multiple log messages for single Request with error 404 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from classic.