Java 调试 JSF + PrimeFaces 应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9772071/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Debugging JSF + PrimeFaces applications
提问by Ariod
Is there a way of debugging JSF + PrimeFaces applications by simply looking at one log file? To be more specific, here is how I personally do it at the moment if something doesn't work as expected:
有没有一种方法可以通过简单地查看一个日志文件来调试 JSF + PrimeFaces 应用程序?更具体地说,如果某些事情没有按预期工作,这是我目前个人的做法:
- Look for visual indicator on the Web page (e.g. if I receive HTTP 500 obviously something is wrong)
- I look in the log file of my application server for any warnings, errors or stacktraces
- I look in the Firebug's network console to see if there were any errors in the HTTP response; this tends to happen from time to time (and it's not shown in the log!)
- I check if it is a validation error by including a
p:message
on the form and display it.
- 在网页上寻找视觉指示器(例如,如果我收到 HTTP 500 显然有问题)
- 我查看我的应用程序服务器的日志文件中是否有任何警告、错误或堆栈跟踪
- 我在 Firebug 的网络控制台中查看 HTTP 响应中是否有任何错误;这往往会不时发生(并且它没有显示在日志中!)
- 我通过
p:message
在表单上包含 a并显示它来检查它是否是验证错误。
For me, checking for errors is a 4-step workflow. Is there a better way of doing this? Ideally, it would be great if all these errors could be logged to a single log. Is this DIY or there is some standard way of doing it?
对我来说,检查错误是一个 4 步工作流程。有没有更好的方法来做到这一点?理想情况下,如果所有这些错误都可以记录到单个日志中,那就太好了。这是 DIY 还是有一些标准的做法?
Thanks!
谢谢!
采纳答案by maple_shaft
There is nothing out of box that will give you what you describe because these are all situations that occur on different layers.
没有任何开箱即用的东西可以为您提供您所描述的内容,因为这些都是发生在不同层上的情况。
This is typically because an unhandled exception made its way up the call stack. If you improve your code for exception handling then these circumstances should be caught and logged.
Improved exception handling and logging at all application layers will help capture all errors and exceptions in a single log file on the application server.
Firebug catches network errors in asynchronous postbacks as well as Javascript exceptions. This is completely a client side concern as the server just derives the markup. It might be possible to catch all Javascript exceptions before they are propagated up to Firebug and to send an asynchronous error report to the server for the server to log. This shouldn't be too terribly difficult to implement.
Again, better logging in your validator methods will be able to put this information in the application server logs so that you have all of this information in one place.
这通常是因为未处理的异常进入了调用堆栈。如果您改进了用于异常处理的代码,那么应该捕获并记录这些情况。
在所有应用层改进的异常处理和日志记录将有助于在应用服务器上的单个日志文件中捕获所有错误和异常。
Firebug 在异步回发和 Javascript 异常中捕获网络错误。这完全是客户端的问题,因为服务器只是派生标记。有可能在所有 Javascript 异常传播到 Firebug 之前捕获它们,并将异步错误报告发送到服务器以供服务器记录。这不应该太难实施。
同样,更好地登录验证器方法将能够将此信息放在应用程序服务器日志中,以便您将所有这些信息集中在一个地方。
The bottom line is that these are all situations where they become a non-issue for developers who learn how to intuitively include good Instrumentation code throughout their applications.
最重要的是,在这些情况下,对于学习如何在整个应用程序中直观地包含良好的 Instrumentation 代码的开发人员来说,它们都不是问题。
回答by user1381361
Hi i am also developing an application using jsf and primefgaces. I also had faced this problem earlier. Now i am using log4j to log all the errors/exceptions/ doubts into a single file. It is also very easy to use it.You can have a look at it, it may solve your problems.
嗨,我也在开发一个使用 jsf 和 primefgaces 的应用程序。我之前也遇到过这个问题。现在我使用 log4j 将所有错误/异常/疑问记录到一个文件中。使用起来也很方便。你可以看看它,它可能会解决你的问题。
回答by Kalpesh Soni
There is also <p:log />
that lets you use PrimeFaces debug.
还有一个可以<p:log />
让你使用 PrimeFaces 调试。