主要内容

本页采用了机器翻译。点击此处可查看英文原文。

使用 API 读取活动日志

MATLAB® Production Server™ API 读取活动日志功能允许您读取 MATLAB Production Server 实例的活动日志,即当前正在写入的主日志。要读取活动日志,请使用GET Active Log

启用用于读取活动日志的 RESTful API

要启用用于读取活动日志的 RESTful API,请取消注释 main_config 文件中的以下条目:

  • --log-endpoint - 此项可启用 API。

  • --log-root - 此条目指定包含日志文件的文件夹,必须启用日志记录。

这些条目也会影响 API 的行为:

  • --log-rotation-size - 此项指定日志在旋转到存档区域之前可以增长的最大大小。它决定了响应的最大大小。

  • log-severity - 此项指定向主日志添加信息的详细程度。

读取活动日志

读取活动日志的 API 包括以下 GET 请求。

GET /api/log HTTP/1.1
Host: localhost:9910

此请求返回主日志的内容。回复正文的格式如下

1 [2025.03.18 13:50:49.510638] [information] Starting master (pid = 10676)
2 [2025.03.18 13:50:49.511635] [information] Global locale: en_US
3 [2025.03.18 13:50:49.511635] [information] Global encoding: UTF-8
4 [2025.03.18 13:50:49.511635] [information] terminal encoding: UTF-8
11 [2025.03.18 13:50:50.168347] [information] -- log directory: "L:\\server\\test_server\\log"
12 [2025.03.18 13:50:50.169334] [information] configuring WebFunction router
13 [2025.03.18 13:50:50.169334] [information] -- loading routes file: .\config\routes.json
122 [2025.03.18 13:50:51.419418] [information] -- UriPathRegexMatcher: removing old entries. operation=add, component=mps_check, entries=0, exists=false

cURL 示例

curl "http://<hostname>:<port>/api/log"

另请参阅

| | (MATLAB Compiler SDK) | (MATLAB Compiler SDK)

主题