开发者

Why is it important to have a logging system when developing a website

开发者 https://www.devze.com 2023-01-07 08:03 出处:网络
What do you do wi开发者_如何学运维th it?How?Etc.(I\'ve just started reading into High Scalability.)How else are you going to find any exceptions?At the very least it is a way to monitor problems with

What do you do wi开发者_如何学运维th it? How? Etc. (I've just started reading into High Scalability.)


How else are you going to find any exceptions? At the very least it is a way to monitor problems with your system, locate errors or log useful information for administration.


This depends in part on the platform you're using. For instance, if you're using ASP.NET, then the built-in ASP.NET Health Monitoring already logs uncaught exceptions for you - there's nothing left for you to do.

I agree that the important points in the lifetime of your site should be made note of. I disagree that traditional text logging is the way to do it. Any logging that is the equivalent of what we used to do with "printf" statements is no better than those "printf" statements. We can do better than that today.

In particular (in the .NET environment), performance counters will often prove to be more useful than logging. Depending on the Operations environment, using WMI may be more appropriate. And in any case, it may be much better to "log" structured data than to log text that then needs to be parsed or else read by a human. "Logging" the context of a problem to an XML column in a database allows sophisticated queries to be performed later to better characterize what's been going on.

It may also be important that the logging is fast enough to use in Production (to some extent). On platforms that support it, .NET allows you to log using ETW, the same code used by device drivers to log. If it's fast enough for them, chances are it's fast enough for your web site.


You'll never anticipate every error when developing. Catch the unexpected exception, send as much detail along with it as you can, because you'll never be able to reproduce it in a debugger.

Edit: send the information in emails, and also log to file in case the emails don't go through. That way, either you have an email if the file system is full, or you have a log if the mail server is down.


If you don't log errors, warnings and debug information, how will you know what went wrong when the site goes down?

It is also a great way to monitor a site's operating 'health'.


I would say a proper logging system is more helpful for maintaining the website after you "finish" your initial development.

As others have stated before, a logging system "keeps" an eye constantly on whatever activities that are happening on your website, and makes a track in case there is anything goes wrong. You might say you never make any mistake when programming, but what if some customer makes a mistake?

I am working as a Technical Support role so I can tell you, the first thing that there is anything goes wrong, the log file and the log database would be the first thing to be checked.

Hope this helps. And good luck, wish you never need to see the log :)


If you are talking about log4j or something similar, you need it because it is better than prints. With prints, they are stuck in your code. With a logging framework, you can put the logging statements and configure your logging for each environment. So you see your debugs in your dev environment and your infos/warns/errors, but not the debugs, in another environment, or anything you want.

You dont need logging to see errors -- exceptions will show up in a stacktrace somewhere.

If you are talking about something different than log4j then I didn't understand the question

0

精彩评论

暂无评论...
验证码 换一张
取 消