简体   繁体   English

生产服务器上的.net调试

[英].net debugging on production server

My team and I are working on a .net web app project for the first time. 我和我的团队第一次在.net网络应用程序项目上工作。 We want to know the most effective way to debug issues on a production server. 我们想知道在生产服务器上调试问题的最有效方法。 Currently, we ftp upload our work to a client's production server. 目前,我们将ftp上传到客户端的生产服务器。

Since our background is in LAMP, we're using to SSHing into the production server, and using a combination of die(), print_r() and comment out techniques to troubleshoot the problem. 由于我们的背景是在LAMP中,我们正在使用SSH连接到生产服务器,并使用die(),print_r()和注释掉技术的组合来解决问题。

Unless I misunderstand the way .net work, I don't think i can use the same approach because changes to .net code behind requires a complete re-build of the project (on localhost), then an upload. 除非我误解了.net的工作方式,否则我认为我不能使用相同的方法,因为对.net代码的更改需要完全重新构建项目(在localhost上),然后上传。 This is too time consuming.... 这太费时了......

Is there a better way to troubleshoot issues on a production server? 有没有更好的方法来解决生产服务器上的问题?

Best troubleshooting tools I know of are Fiddler, Firebug and Glimpse 我所知道的最好的故障排除工具是Fiddler,Firebug和Glimpse

Fiddler 提琴手

FireBug 萤火

Glimpse 一瞥

When dealing with production issues, its best to have an environment that replicates production. 在处理生产问题时,最好有一个复制生产的环境。 In that environment you can deploy the same app, but with debug enabled. 在该环境中,您可以部署相同的应用程序,但启用了调试。 This would allow for you to have a whole suite of tools you dont want available in production. 这将允许您拥有一整套您不想在生产中使用的工具。

Once armed with this environment, all you need is to find out where the exception is happening (through logging/tracing) and how to reproduce the problem. 一旦掌握了这个环境,你所需要的就是找出异常发生的位置(通过记录/跟踪)以及如何重现问题。

The issue is production environments are design to be fast (no debugging, minimal logging) and secure. 问题是生产环境设计得很快(没有调试,最小的日志记录)和安全。 So admins hate things like debugging or even the concept of remote debugging. 所以管理员讨厌调试甚至远程调试的概念。

The goal of well designed architecture/production software, is to collect enough information about what went wrong, so you can reproduce the error/scenario in another environment. 精心设计的架构/生产软件的目标是收集有关出错的足够信息,以便您可以在其他环境中重现错误/场景。

There are a variety of different logging frameworks for you to choose from that you can change the settings without the need of a rebuild. 有多种不同的日志框架供您选择,您可以在不需要重建的情况下更改设置。 You can set the logging level within a config file, Eg. 您可以在配置文件中设置日志记录级别,例如。 Error, Warning, Debug, etc... 错误,警告,调试等......

You include instrumentation code for all logging levels in your application and those log statements will only execute if the log level is set. 您在应用程序中包含所有日志记录级别的检测代码,并且只有在设置了日志级别时才会执行这些日志语句。

Here is an example of one such offering. 这是一个这样的产品的例子。

http://msdn.microsoft.com/en-us/library/ff647183.aspx http://msdn.microsoft.com/en-us/library/ff647183.aspx

There are really only three ways to debug server side issues. 实际上只有三种方法可以调试服务器端问题。

Logging Plan ahead and add logging to your application. 提前记录计划并将日志记录添加到您的应用程序。 Most logging frameworks like log4net and Enterprise library have modes to log more or less information depending on a configuration setting. 大多数日志框架(如log4net和Enterprise库)都具有根据配置设置记录更多或更少信息的模式。 IIS also has its own logging that you can look at. IIS也有自己的日志记录,您可以查看。

Instrumentation You can add performance counters to your application and also use the existing performance counters if you are having a performance issue. 检测您可以向应用程序添加性能计数器,如果遇到性能问题,还可以使用现有的性能计数器。 Also tools available from Sysinternals and WireShark can come in handy for problems outside of your code. 此外,Sysinternals和WireShark提供的工具可以为您的代码之外的问题提供方便。

Memory Dumps You can capture memory dumps of your application and use a tool like WinDbg to look at a snapshot of what's going on in your system. 内存转储您可以捕获应用程序的内存转储,并使用WinDbg之类的工具查看系统中正在发生的事件的快照。

The stack traces provided in .NET, once you learn to understand them, provide often enough value to really track down an error. .NET中提供的堆栈跟踪,一旦您学会理解它们,就能提供足够的价值来真正追踪错误。 You can enable remote debugging but since it's a client's machine and it's a real pain in the butt, I would avoid that. 你可以启用远程调试,但因为它是客户端的机器而且它是一个真正的痛苦,我会避免这种情况。

Mostly you make sure you have test coverage, understand how to read exceptions, and take some time thinking about exceptions you see. 大多数情况下,您确保自己拥有测试覆盖率,了解如何阅读异常,并花些时间考虑您看到的异常。 In 10 years of .NET work I have only wanted to debug on a production server once and I ended up finding out the bug without that. 在10年的.NET工作中,我只想在生产服务器上进行一次调试,最后我发现了没有它的bug。

Also, you can use ELMAH to capture unhandled exceptions, which is helpful. 此外,您可以使用ELMAH捕获未处理的异常,这很有帮助。

Debugging should happen at development phase with "debug" option enabled. 调试应在开发阶段进行,并启用“debug”选项。 When you deploy to Production turn off "debug" option for efficiency. 部署到生产时,请关闭“调试”选项以提高效率。 In production, however you can log the error/exceptions/stack traces etc in a log file which will help you to troubleshoot the issue at hand. 但是在生产中,您可以在日志文件中记录错误/异常/堆栈跟踪等,这将帮助您解决手头的问题。

Again, those die(), print_r() are perl debugging way since perl don't have any built in exception OR error tracing mechanism. 同样,那些die(),print_r()是perl调试方式,因为perl没有任何内置异常或错误跟踪机制。 That way it don't work in case of .NET. 这样它在.NET的情况下不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM