如何使用QTP读取*.log文件?

发布于 2024-12-24 16:53:20 字数 231 浏览 1 评论 0原文

我必须编写自动测试来验证服务器日志的正确性。我如何使用 QTP 来做到这一点。这些日志文件非常长,因此需要花费大量时间逐行执行此操作。

日志文件中各行的格式如下:

2012-01-04 14:26:08,832|DEBUG|company.project.algorithm.core.AlgorithmCore - No primary operation was found.

I have to write automatic test verifying correctness of server logs. How can I do this using QTP. Those log files are very long so it takes a lot of time to do this line after line.

Format of the lines in log file is as follows:

2012-01-04 14:26:08,832|DEBUG|company.project.algorithm.core.AlgorithmCore - No primary operation was found.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

末骤雨初歇 2024-12-31 16:53:20

您还没有澄清您的问题,所以我将回答两个可能的问题。

  • 从 QTP 11 开始,对于使用 log4X(log4j、 log4net 等)日志框架。
  • 如果您只想验证是否创建了有效的日志,则需要解析日志文件,这与 QTP 直接无关。您可以使用纯 VBScript 执行此操作并从测试中运行它,也可以使用其他语言(.NET 或 COM)执行此操作并从测试中调用它(例如,通过使用 QTP 的 DotNetFactory)。

You haven't clarified your question so I'll give answers to two possible questions.

  • Starting with QTP 11 there is an option to listen to an applications log messages via the Log Tracking feature (available in the Test Settings), for applications using a log4X (log4j, log4net etc) logging framework.
  • If all you want to do is verify that a valid log was created you need to parse the log file, this has nothing to do with QTP directly. You can either do it in plain VBScript and run it from a test or you can do it in another language (.NET or COM) and call it from the test (e.g. by using QTP's DotNetFactory).
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文