Elmah is only logging 15 Errors - c#

I've just starting looking at a site in place at work. They're using Elmah to log errors.
It seems to be logging fine, but in the web interface, when I tell Elmah to show me 100 errors per page, it only shows the most recent 15.
Then when I click on "Download Log" I only get shown 15 errors in the CSV.
Anyone know how I can configure it to keep all the errors?
Or can someone point me to some docs on how to do this?
Thanks a lot!
-Evan

Looks like there is no database configured to log errors to.
By default it only logs the last 15 errors to memory if it has no where to write it to...

Related

.NET 5 - Correctly handling expected 404 or 400 errors in a web API

I'm looking for a correct way to handle the expected errors in my web API.
For example, i have a endpoint with 2 possible responses.
200 OK, with a result object
404 Not Found, with a ApiError object, containing a small (localized) message and title.
Currently i'm throwing an custom exception at the place in my code where i know if the resource is a Ok or Not found. I got a custom middleware in place to catch these exceptions and create a nice formatted ApiError.
This works perfect, except all these (known) messages are also logged inside my log files/Application Insights. It feels weird to add a boolean to this exception where i can specify if the exception should be logged. But currently this feels like the only possible way.
Is there any advice that could make this implementation beter or maybe i should change the implementation?
Well, the issue is not .NET 5 - it is application insight.
Your middleware basically should tell AI that those specific errors ARE NOT ERRORS.
https://peter.intheazuresky.com/2020/08/21/let-application-insights-focus-on-real-problems-and-not-missing-data-404-in-your-apis/
Basically, get the ITelemetryInterface from ApplicationInsight and tell of that despite the error code, the request was a success.
Voila, problem solved. AI can not magically know that specific 404 errors are "expected" as normal operations - you will have to help it out.
It makes sense to track them on a website / web application level. It does not make sense to treat them as errors on the backend level. The response (not found) is perfectly valid, from the point of an API. Just configure AI accordingly.

iis8 detailed error logging to file

I can get Detailed Error logging to screen (local/remote etc). But what I really want is to log "Detailed Error" to file.
Does this exist?
I checked all the documentation that I can find, and for the life of me i can't see how to do this.
I don't understand why this wouldn't be a requested feature - something that sits halfway between "no logs" and processor-intensive "failed request tracing".
If you are working with asp.net and want a drop in "write my errors to a log file" without making code changes, take a look at elmah
The "pure" IIS solution is Failed Request Tracing.

Is Java/1.6.0_24 a Bot and How to force them to refresh their link

We've now got plenty of sites which all use a log4net base error loging framework and we receive error from site from anywhere it append. We've notice that some of them catch error because of "Bot" like google, bing, yahoo, etc. But there's a things we've not sure about how to resolve. I've two questions about it :
Is "Java/1.6.0_24" a Bot? Because the user-agent of my question #2 is about this.
The "Java/1.6.0_24" still calling subfolder on our site that just do not exists! Like, if we have a page called "Page1.aspx", instead of calling "~/Page1.aspx", he calls it "~/minisite/Page1.aspx". How can I tell him he's wrong? Is there a way to do it?
Thanks you
It's most likely a bot but it could as well be some kind of browser based on Java that sends that user-agent string - you can't trust it 100% but it can give you an estimate idea of what the connecting entity is. Depending on the kind of bot it might as well just ignore your robots.txt so I'd just impement some handling stuff somewhere.
Did those folders ever exist? If so, you could use HTTP's permanent redirect (code 301) to tell him to no longer look there - however that doesn't guarantee it will do so.

How to show the custom message when database down

I have deployed the web application and customer accessing web application publically in between my databse down then I want show the custom message to the user. In my web application 50 pages, and I want to handle message commonly for all pages. Please help how to do this.
You can configure a section in web.config that tells ASP.NET/IIS to redirect users to a set of static or dynamic pages in case of common errors.
Check out this article - http://www.asp.net/hosting/tutorials/displaying-a-custom-error-page-cs
The scenario is pretty similar - something goes wrong with the SQL DB call and you dont want to display an ugly error.
Make sure to include some sort of logging somewhere so that you know these errors are happing, however. One plus side of ugly error messages are that you'll hear about them right away ;)

Sending 500 Error Information To Yourself

Where would I need to hook in (at what event) to be able send myself every 500 error that happens on my current ASP.NET project. Something inside the global.asax? And I'd like to send myself the output that the user would see. The white/yellow/black 500 standard ASP.NET error HTML.
My users only see the errors about 10% of the time. The other 90% these are Ajax responses.
You can do this in global.asax.cs using Global Error Handling in ASP.Net using the Application_Error(...) method
If you're more interested in the end result than in the process of making it work yourself, you might like to take a look at the Elmah ("Error Logging Modules and Handlers") project - http://code.google.com/p/elmah/
It's allows you to do many things with errors - send email notifications, log them to a database, browse the error log via a web interface, and even crazy things like an RSS feed of errors or using Twitter to tweet errors.
It's quite easy to install and configure.

Categories

Resources