Java 适配器中的日志记录

improve this page | report issue


概述

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

日志记录示例

导入 java 日志记录包:

import java.util.logging.Logger;

定义记录器:

static Logger logger = Logger.getLogger(JavaLoggerTestResource.class.getName());

现在,在方法内包含日志记录:

logger.warning("Logging warning message...");

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

访问日志文件

将日志转发到分析服务器

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

  1. 在 MobileFirst Operations Console 中,选择侧边栏导航中的设置选项。
  2. 单击“运行时属性”选项卡中的编辑按钮。
  3. 分析 → 更多程序包部分,指定 Java 适配器的类名(例如 com.sample.JavaLoggerTestResource),以将日志转发到 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