简体   繁体   English

如何在部署的应用程序中从海边记录堆栈跟踪

[英]How to log stack traces from seaside in deployed application

When developing in seaside the stack traces are printed into the browser.在海边开发时,堆栈跟踪会打印到浏览器中。 When deploying the application I don't want users to see this information but I would like a log of any stack traces on the server side for debugging.部署应用程序时,我不希望用户看到此信息,但我希望在服务器端记录任何堆栈跟踪以进行调试。 In my current app I have the following configuration :在我当前的应用程序中,我有以下配置

ZnZincServerAdaptor startOn: 1701.

ZnZincServerAdaptor default server logLevel: 2; logToTranscript.

WAAdmin clearAll.
WAEnvironment configureApplicationDefaults.
WAEnvironment registerDefaultRequestHandlers.
WAAdmin applicationDefaults removeParent: WADevelopmentConfiguration instance.
WAAdmin applicationExceptionHandlingDefaults at: #exceptionHandler put: WAErrorHandler.
BabyTrackerApp initialize.
WAAdmin defaultDispatcher defaultName: 'babytracker'.

Transcript show: 'Baby Tracker started'; cr

Which I initially copied from svenvc/reddit on GitHub.我最初是从 GitHub 上的svenvc/reddit复制的。

What I find with this setup is that there is logging on the server when requests come in, but not the stack traces of any errors only the one line summary showing the time of the request and the HTTP status code.我在这个设置中发现,当请求进入时,服务器上有日志记录,但没有任何错误的堆栈跟踪,只有显示请求时间的一行摘要和 HTTP 状态代码。

What additional configuration is needed to log the stack traces?需要什么额外的配置来记录堆栈跟踪?

Every Seaside request is handled within a chain of request handlers, one of which is the "Error Handler" (usually the one at the top of the request processing), the default error handler during development will enable you to debug the app, and the one in your snippet is the WAErrorHandler , which will print the exception in basic HTML and send it to the user.每个 Seaside 请求都在请求处理程序链中处理,其中一个是“错误处理程序”(通常位于请求处理的顶部),开发期间的默认错误处理程序将使您能够调试应用程序,并且您的代码段中的一个是WAErrorHandler ,它将在基本 HTML 中打印异常并将其发送给用户。

You can define your own subclass of WAErrorHandler , and use that newly defined class as your Error Handler class.您可以定义自己的WAErrorHandler子类,并将新定义的 class 用作您的错误处理程序 class。

You define such handler class in the following statement:您在以下语句中定义此类处理程序 class:

WAAdmin applicationExceptionHandlingDefaults 
  at: #exceptionHandler put: WAErrorHandler.

Recently I started using Sentry to log all the exceptions, and for that I defined my own exception handler class that will report the exception to Sentry's server and enable me to analyze issues using a better platform.最近我开始使用Sentry来记录所有异常,为此我定义了我自己的异常处理程序 class,它将向 Sentry 的服务器报告异常并使我能够使用更好的平台分析问题。

You can find such integration in this repository: https://github.com/eMaringolo/seaside-sentry您可以在此存储库中找到此类集成: https://github.com/eMaringolo/seaside-sentry

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

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