通过 Dynamicloud 的 Lonline 记录您的应用程序的信息

发布日期:2026-07-13 10:23:02   来源 : 杭州电子商务研究院    浏览量 :14
杭州电子商务研究院 发布日期:2026-07-13 10:23:02  
14

可用性

让我们开始考虑可用性

“系统的可用性通常以其可靠性来衡量——可靠性越高,可用性也就越高。”(维基百科)

在尝试创建可靠的系统时,可用性非常重要。但是,我们如何提供这种系统以及如何创建/提供让我们感到舒适的东西?


可靠系统或应用程序的特点

  • 始终可用
  • 使用一整套测试用例构建
  • 包含集成的诊断工具
  • 具有实时监控
  • 限制外部客户端的访问
  • 实时记录所有潜在错误

实时记录每个潜在错误

在开发应用时,记录程序是一项重要任务,因为它可以让您更详细地了解应用的行为和性能。这样,每当您发现产品中的错误时,您就可以构建修复程序并执行决策。

现在检查日志结果非常困难,因为日志通常驻留在服务器、虚拟化、虚拟服务器或云服务中。

介绍

Lonline允许您将程序登录到云中,并由 Dynamicloud 服务提供支持。基于云的日志记录避免了服务器访问和磁盘使用。Lonline 提供 6 个级别的日志记录和 2 种执行报告的方法。其 Dynamicloud 服务方便了数据存储和访问。此外,Lonline 允许您设置更多功能,从而跟踪的不仅仅是文本、级别和程序轨迹。

在本指南中,我将介绍以下内容:

  1. 依赖项
  2. 设置
  3. 安装
  4. Dynamiccloud 帐户
  5. 如何使用
  6. 使用六个级别进行记录
  7. 其他数据
  8. 执行报告
  9. 故障排除

依赖项

Lonline 有一个依赖项: Dynamicloud Nodejs API

Dynamicloud还提供 Java 和 Ruby 语言的 API,因此您可以在 Java 或 Ruby 程序中使用 Lonline。

安装

您可以使用 Node 包管理器 (npm) 命令在系统中安装此模块:

npm 安装 lonline

设置

Lonline 需要配置基本设置。这些设置位于 Lonline 软件包附带的“设置”文件中。

这些是 Lonline 的设置:

      /**
 * Options Documentation:
 */
var ops = {
     //OPTIONAL: This is the current logger object you're using in your program.
     //Lonline will call the same function in legacy object, for example:
     //lonlineLogger.error("It couldn't process the data");
     // The line above will execute the method error from legacy object passing the log
     // and the error as follow:  legacyObject.error(log, error);
     legacy: myOwnLogger
     //OPTIONAL: This attribute indicates the path to load the settings, if this attribute is present all the
     //below attributes will be skipped.
     //This file must be a compatible json file.
     fileName: '../setting.json',
     //This attribute indicates the level of lonline
     //The following table is an explanation of levels in Lonline (Descriptions from the great Java Log4j library):
     //------------------------------------------------------------------------------------------------------------
     //| Level      | Activated levels           | Description                                                    |
     //------------------------------------------------------------------------------------------------------------
     //| fatal      | Fatal                      | Designates very severe error events that will presumably lead  |
     //|            |                            | the application to abort.                                      |
     //------------------------------------------------------------------------------------------------------------
     //| error      | Fatal, Error               | Designates error events that might still allow the application |
     //|            |                            | to continue running.                                           |
     //------------------------------------------------------------------------------------------------------------
     //| warn       | Fatal, Error, Warn         | Designates potentially harmful situations.                     |
     //------------------------------------------------------------------------------------------------------------
     //| info       | Fatal, Error, Warn, Info   | Designates informational messages that highlight the progress  |
     //|            |                            | of the application at coarse-grained level.                    |
     //------------------------------------------------------------------------------------------------------------
     //| debug      | Fatal, Error, Info, Warn   | Designates fine-grained informational events that are most     |
     //|            | Debug                      | useful to debug an application.                                |
     //------------------------------------------------------------------------------------------------------------
     //| trace      | All levels                 | Traces the code execution between methods, lines, etc.         |
     //------------------------------------------------------------------------------------------------------------
     //| off        | None                       | The highest possible rank and is intended to turn off logging. |
     //------------------------------------------------------------------------------------------------------------
     level: 'error',
     //Credentials for REST APIs
     //Go to https://www.dynamicloud.org/manage and get the API keys available in your profile
     //If you don't have an account in Dynamicloud, visit https://www.dynamicloud.org/signupform
     //You can easily use a social network to sign up
     csk: 'csk#...',
     aci: 'aci#...',
     //This is the model identifier for test and development environment
     //The model contains the structure to store logs into the cloud
     //For more information about models in Dynamicloud visit https://www.dynamicloud.org/documents/mfdoc
     modelIdentifier: 000,
     //OPTIONAL: Shows every warning like rejected request from Dynamicloud and other warnings in lonline
     warning: true,
     //OPTIONAL: report_limit indicates how many records lonline will execute to fetch data from Dynamicloud.
     //If you need to increase this value, please think about the available requests per month in your account.
     //Dynamicloud uses a limit of records per request, at this time the max records per request is 20.  So,
     //report_limit=100 are 5 request.
     reportLimit: 100,
     //Send the backtrace (the ordered method calls) of the log.  If you want to avoid this sets to false
     backtrace: true,
};
    

Lonline 允许您将设置放入文件中。必须通过属性fileName传递文件的路径。

      //OPTIONAL: This attribute indicates the path to load the settings, if this attribute is present all the
//below attributes will be skipped.
//This file must be a compatible json file.
fileName: "../settings.json";
    

设置.json

      {
  "csk": "csk#...",
  "aci": "aci#...",
  "modelIdentifier": 000,
  "backtrace": true,
  "level": "trace"
}
    

Dynamiccloud 帐户

Lonline 需要 Dynamicloud 帐户的 API 凭据。这些凭据允许 Lonline 访问您帐户的结构(模型)。您帐户中的必需模型应由至少包含三个字段的模型组成。有关 Dynamicloud 中的模型和字段的更多信息,请访问其文档“模型和字段”

*让我们在 Dynamicloud 中设置您的帐户。别担心,这很容易:**

  1. 在 Dynamiccloud 中注册(您可以使用 Google、Linkedin 或 Github 帐户来加快注册速度)
  2. 单击实时仪表板上的“添加字段”链接。这里您需要添加三个字段:

a.字段:

字段标识符 字段标签 现场评论 字段类型 表单中有必填字段吗?
線上文本 日志文本 包含此日志的踪迹 文本区域 是的
网上水平 日志级别 包含日志级别 组合框 是的
网上追踪 完整追踪 包含日志的完整踪迹 文本区域

b. lonlinelevel是一个组合框。您需要添加以下选项:

价值 文本
致命的 致命的
错误 错误
警告 警告
信息 信息
调试 调试
痕迹 痕迹

要添加这些选项,请按照以下步骤操作:

  1. 单击实时仪表板上的“全局字段”链接
  2. 在字段表中,找到标识符为lonlinelevel的行
  3. 点击管理项目链接。将显示一个空的项目列表,然后单击添加新按钮并填写值和文本字段
  4. 步骤三应执行六次:每个可用级别(严重、错误、警告、信息、调试和跟踪)执行一次。

c.添加模型

模型是这些字段的容器。要添加模型:

  1. 单击实时仪表板上的添加模型链接
  2. 填写必填字段名称并设置描述(可选)
  3. 按下按钮创建
  4. 在模型列表中,模型框有一个带有模型 ID 的标题,复制该 ID 并将其放入您的settings.json文件中。
<div class="code-
以上内容来自杭州电子商务研究院推送
关注
关于我们
热门推荐
合作伙伴
免责声明:本站部分资讯来源于网络,如有侵权请及时联系客服,我们将尽快处理
Copyright © 2025-2027 ToB产业网址导航 公安备案 浙公网安备33010602013138号 浙ICP备16025413号-9
支持 反馈 关注 数据