简体   繁体   English

您如何看待在特殊日志表中保存堆栈跟踪?

[英]What do you think of saving stack trace in a special log table?

Suppose, you have a special log table of your application. 假设您有一个特殊的应用程序日志表。

What do you think about creating a BLOB field for a possible stack trace ? 您如何为可能的堆栈跟踪创建BLOB字段?

Logging is done to file as well, but it is not so convenient to read a text file, moreover database is more "accessible". 记录也是对文件进行的,但是读取文本文件并不方便,而且数据库更“可访问”。

What if the stack trace is due to a database connection failure? 如果堆栈跟踪是由于数据库连接失败怎么办? Some things need to be as low-level and simple as possible. 有些事情需要尽可能低级和简单。 Also, I don't see why a database should be any more or less accessible than a file share or ssh account. 此外,我不明白为什么数据库应该比文件共享或ssh帐户更多或更少可访问。

Duplicate logging sounds like... well, duplicate logging. 重复记录听起来像......好吧,重复记录。 Overhead. 高架。 If you need to access the logs through database, I would rather use/write a tool that can import the logs to a separate database when needed. 如果您需要通过数据库访问日志,我宁愿使用/编写一个工具,可以在需要时将日志导入到单独的数据库中。 Or make them accessible by some other means. 或者通过其他方式使它们可以访问。 One tool that I know of is Splunk, but it's expensive and I'm sure there are others too. 我知道的一个工具是Splunk,但它很昂贵,而且我确信还有其他工具。

I previously worked on an application where this happened, but as Marcelo Cantos suggests, it was never really reliable because certain exceptions couldn't be logged there, so we never used it and always relied on log files instead. 我以前曾在一个应用程序中进行过这种情况,但正如Marcelo Cantos所说,它从来都不可靠,因为某些异常无法记录在那里,因此我们从未使用它,而是始终依赖于日志文件。

If you use the log file to debug errors, you'll also get any other debug of info messages you choose to print, in the correct order; 如果您使用日志文件来调试错误,您还将以正确的顺序获得您选择打印的任何其他信息消息调试; it's rare that all you need is a stack trace, usually what led up to the stack trace is equally if not more useful. 很少有你需要的只是堆栈跟踪,通常导致堆栈跟踪的内容同样如果不是更有用。

Why ? 为什么? Or at least, if you're going to do it, why the Blob field ? 或者至少,如果你要这样做,为什么Blob领域呢?

If I were to implement something like this, I would separate the exceptions into separate StackTraceElements and store those into a proper table. 如果我要实现这样的东西,我会将异常分成单独的StackTraceElements并将它们存储到适当的表中。 Over time and a variety of failures, you might generate some interesting statistics about the nature of risk and quality within your application. 随着时间的推移和各种各样的失败,您可能会在应用程序中生成一些有关风险和质量性质的有趣统计数据。

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

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