查看由工作流启动的脚本记录的日志

View logs recorded by workflow initiated scripts

我刚开始使用 AEM,我正在尝试使用一些基本脚本设置工作流程。我现在有最简单的 ecmascript 来记录变量。我的问题是,我要记录的字符串在哪里?是否有我需要在 configMgr 中设置的记录器,或者是否有现有的日志文件?

function getParticipant() {
    log.info("assigning approvers...");
    var path = workItem.getWorkflowData().getPayload().toString();
    log.info("itemPath: " + path);
    return workItem.getWorkflow().getInitiator();
}

谢谢

默认情况下,所有内容都会进入您的 /log/error.log 文件,除非另有配置。

log.info 仅当您的日志记录设置为 INFO 级别(或以下,即 DEBUG 等)时才可见。

以下是 AEM 中可用的日志文件

access.log -- All access requests to AEM/CQ5 and the repository are registered here.

request.log -- Each access request will be logged here with response

error.log -- Error messages (of varying levels of severity like INFO, ERROR, DEBUG, etc.) are registered here.

stderr.log -- error messages of varying levels of severity, generated during startup. By default the log level is set to Warning (WARN)

stdout.log -- logger messages indicating events during start up.

upgrade.log -- Provides a log of all upgrade operations that runs from the com.day.compat.codeupgrade and com.adobe.cq.upgradesexecutor packages.

要拥有自己的记录器文件,您可以

Add a logger configurations in AEM as shown below.

示例,如果我必须为 我的 OSGi 服务(记录器)设置 info 级别记录器 *com.mycompany.myrestservice*

日志编写器将所有这些消息写入您定义的物理文件。

  1. 登录 Felix 控制台:http://<host>:<port>/system/console/configMgr
  2. 从“Factory Configurations”创建“Apache Sling Logging Writer Configuration”
  3. 将“日志文件”的值设置为 "../logs/restservice.log" 点击 "Save"

Logging Logger 获取此消息并根据您的规范对其进行格式化。

  1. 从“Factory Configurations”创建“Apache Sling Logging Logger Configuration”
  2. 将“日志级别”的值设置为"Info"
  3. 将“日志文件”的值设置为 "../logs/restservice.log"
  4. 添加“记录器”=> com.mycompany.myrestservice
  5. 点击"Save"

Below are the advantages that you will get by custom loggers

  1. 具体的日志记录级别 -- 我已将其设置为 Info
  2. 单个日志文件的位置 -- 我已将其设置为 /logs/restservice.log
  3. 要保留的版本数 -- 我已将其设置为 5
  4. 版本轮换;最大尺寸或时间间隔——我保留默认值
  5. 写入日志消息时使用的格式 -- 我保留为默认值
  6. 记录器(提供日志消息的 OSGi 服务)——我已将其设置为我的 OSGI 服务 com.mycompany.myrestservice