JavaScript 适配器中的日志记录

improve this page | report issue


概述

本教程提供在 JavaScript 适配器中添加日志记录功能所需的代码片段。

日志记录示例

下面的消息输出至应用程序服务器的 trace.log 文件。 如果服务器管理员正在从 MobileFirst Server 向 MobileFirst Analytics Server 转发日志,那么 logger 消息还将显示在 MobileFirst Analytics Console 的基础架构 → 服务器日志搜索视图中。

MFP.Logger.debug("This is a debug message from a JavaScript adapter");

从最低到最高详细度的其他日志记录级别为:ERROR、WARN、INFO、LOG 和 DEBUG。

访问日志文件

将日志转发到分析服务器

也可以将日志转发至分析控制台。

  1. 在 MobileFirst Operations Console 中,选择侧边栏导航中的设置选项。
  2. 单击“运行时属性”选项卡中的编辑按钮。
  3. 分析 → 更多程序包部分,指定 MFP.Logger,以将 JavaScript 适配器日志转发至 MobileFirst Server。

从控制台进行日志过滤

Inclusive terminology note: The Mobile First Platform team is making changes to support the IBM® initiative to replace racially biased and other discriminatory language in our code and content with more inclusive language. While IBM values the use of inclusive language, terms that are outside of IBM's direct influence are sometimes required for the sake of maintaining user understanding. As other industry leaders join IBM in embracing the use of inclusive language, IBM will continue to update the documentation to reflect those changes.
Last modified on June 01, 2020