机器人
2023.4
False
横幅背景图像
机器人用户指南
上次更新日期 2024 年 2 月 27 日

机器人日志

日志是带有时间戳的文件,其中包含与应用程序相关的信息事件、错误和警告消息。

以下页面显示了日志的类型:

机器人执行日志

机器人执行日志是由流程执行生成的消息。其中包含与其行为相关的信息以及工作流中用户定义的消息。

执行日志由以下内容生成:

  • “写入行”活动会创建“Trace”级别的日志。
  • “日志消息”活动,用于创建在活动的“级别”属性字段中指定的级别的日志。
  • 运行自动化项目,该项目会生成包含每个活动行为的日志。对于 Assistant 的“Orchestrator 设置”窗口中的“级别”设置,如果已将其设置为“Verbose”,则这些日志会使用 Trace 级别。

执行日志的日志记录级别

默认的日志记录级别由“Orchestrator 设置”窗口中的“级别”设置控制。该设置默认为“Information”

注意:在 Orchestrator 中为机器人设置的日志级别将覆盖在 UiPath Assistant 中设置的日志级别

通过 Assistant 更改默认日志记录级别:

  1. 在 UiPath Assistant 中,转到“首选项”菜单,然后访问“Orchestrator 设置”
  2. 在“日志记录”部分的“日志级别”下拉菜单中,选择所需的日志记录级别。



    注意:如果是以服务模式安装的机器人,则需要管理员权限才能编辑此设置。

Orchestrator 目标

如果机器人已连接到 Orchestrator,则所有执行日志都将发送到 Orchestrator,您可以在“日志”页面中进行查看。

如果 Orchestrator 处于不可用状态,则在连接恢复前,系统会将日志存储在可用磁盘空间的本地数据库 (C:\Windows\SysWOW64\config\systemprofile\AppData\Local\UiPath\Logs\execution_log_data) 中。恢复连接后,系统会按日志的生成顺序将其分批发送。
注意:将日志成功发送至 Orchestrator 后,系统不会删除此数据库。

NLog 目标

另外,可以通过编辑 <Installation Folder>\NLog.config 文件来配置日志目标和内容。
日志的目标位置由 <Installation Folder>\NLog.config 文件控制。“内部”类型记录器会收集诊断日志,通过使用 NLog 目标即可转发该类日志。
执行日志默认存储在 %LocalAppData%\UiPath\Logs 文件夹的某个文件中。“WorkflowLogging”记录器会收集消息,通过使用 NLog 目标即可转发该类日志,如下方 NLog.config 文件中的参数所示:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <variable name="WorkflowLoggingDirectory" value="${specialfolder:folder=LocalApplicationData}/UiPath/Logs" />
  <rules>
    <logger name="WorkflowLogging" writeTo="WorkflowLogFiles" final="true" />
  </rules>
  <targets>
    <target type="File" name="WorkflowLogFiles" fileName="${WorkflowLoggingDirectory}/${shortdate}_Execution.log" layout="${time} ${level} ${message}" keepFileOpen="true" openFileCacheTimeout="5" concurrentWrites="true" encoding="utf-8" writeBom="true" />
  </targets>
</nlog><?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <variable name="WorkflowLoggingDirectory" value="${specialfolder:folder=LocalApplicationData}/UiPath/Logs" />
  <rules>
    <logger name="WorkflowLogging" writeTo="WorkflowLogFiles" final="true" />
  </rules>
  <targets>
    <target type="File" name="WorkflowLogFiles" fileName="${WorkflowLoggingDirectory}/${shortdate}_Execution.log" layout="${time} ${level} ${message}" keepFileOpen="true" openFileCacheTimeout="5" concurrentWrites="true" encoding="utf-8" writeBom="true" />
  </targets>
</nlog>

删除旧的工作流日志文件

为避免创建大量日志文件占用计算机上的磁盘空间,您可以选择在达到特定文件数量后存档日志文件。

为此,请在 <target> 标签 NLog.config 中添加以下参数:
  • archiveNumbering="Date"
  • archiveEvery="Day"
  • archiveDateFormat="yyyy-MM-dd"
  • archiveFileName="${WorkflowLoggingDirectory}/{#}_Execution.log"
  • maxArchiveFiles="10"

    <?xml version="1.0" encoding="utf-8" ?>
    <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <variable name="WorkflowLoggingDirectory" value="${specialfolder:folder=LocalApplicationData}/UiPath/Logs" />
      <rules>
        <logger name="WorkflowLogging" writeTo="WorkflowLogFiles" final="true" />
      </rules>
      <targets>
        <target type="File"
          name="WorkflowLogFiles"
          fileName="${WorkflowLoggingDirectory}/${shortdate}_Execution.log"
          layout="${time} ${level} ${message}"
          keepFileOpen="true"
          openFileCacheTimeout="5"
          concurrentWrites="true"
          encoding="utf-8"
          writeBom="true"
          archiveNumbering="Date"
          archiveEvery="Day"
          archiveDateFormat="yyyy-MM-dd"
          archiveFileName="${WorkflowLoggingDirectory}/{#}_Execution.log"
          maxArchiveFiles="10"
        />
      </targets>
    </nlog><?xml version="1.0" encoding="utf-8" ?>
    <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <variable name="WorkflowLoggingDirectory" value="${specialfolder:folder=LocalApplicationData}/UiPath/Logs" />
      <rules>
        <logger name="WorkflowLogging" writeTo="WorkflowLogFiles" final="true" />
      </rules>
      <targets>
        <target type="File"
          name="WorkflowLogFiles"
          fileName="${WorkflowLoggingDirectory}/${shortdate}_Execution.log"
          layout="${time} ${level} ${message}"
          keepFileOpen="true"
          openFileCacheTimeout="5"
          concurrentWrites="true"
          encoding="utf-8"
          writeBom="true"
          archiveNumbering="Date"
          archiveEvery="Day"
          archiveDateFormat="yyyy-MM-dd"
          archiveFileName="${WorkflowLoggingDirectory}/{#}_Execution.log"
          maxArchiveFiles="10"
        />
      </targets>
    </nlog>
    注意:maxArchiveFiles 是控制存档文件数量的参数。
    注意:编辑 NLog.config 文件需要管理员权限。无需重新启动机器人服务即可使更改生效。

深入编辑日志

如果日志记录级别设置为 Verbose,则消息将包含有关在执行时运行的活动的所有详细信息。可以通过编辑 C:\Program Files\UiPath\Studio 文件夹中的 UiPath.Executor.exe.config 文件来自定义此日志输出。
为此,必须在 <system.serviceModel> 标签下添加以下 XML 代码。
<tracking>
    <profiles>
        <trackingProfile name="StandardProfile">
         <workflow>
          <activityStateQueries>  
            <activityStateQuery activityName="*">
                <states>  
                    <state name="Faulted"/>  
                </states>
                <arguments>  
                    <argument name="*"/>  
                </arguments> 
                 <variables>  
                    <variable name="*"/>  
                </variables>             
            </activityStateQuery>
          </activityStateQueries>    
         </workflow>
        </trackingProfile>       
    </profiles>
</tracking><tracking>
    <profiles>
        <trackingProfile name="StandardProfile">
         <workflow>
          <activityStateQueries>  
            <activityStateQuery activityName="*">
                <states>  
                    <state name="Faulted"/>  
                </states>
                <arguments>  
                    <argument name="*"/>  
                </arguments> 
                 <variables>  
                    <variable name="*"/>  
                </variables>             
            </activityStateQuery>
          </activityStateQueries>    
         </workflow>
        </trackingProfile>       
    </profiles>
</tracking>
鉴于 <states> 标签仅包含 <state name="Faulted"/>,因此插入以上代码只能记录拥有“Faulted”(出错)状态的活动。在 <states> 标签下添加其他参数(例如 <state name="Executing"/>)也会记录拥有其他状态的活动。

不仅可以修改活动状态,还可以修改变量和参数。如需详细了解自定义的相关信息,请参见此处

注意:修改 UiPath.Executor.exe.config 文件后,您需通过重启机器人服务使更改生效。

机器人诊断日志

机器人诊断日志提供与机器人本身及其上下文相关的信息。这些信息可用于确定特定错误的原因。

机器人诊断日志保存在以下位置:

  • 在 Windows 上,与错误相关的诊断日志记录在事件查看器中。
  • 在包括 Windows 在内的所有平台上,Verbose 日志都将写入文件:

    • Windows 上的 %LocalAppData%\UiPath\Logs\internal\Robot.log(当机器人以用户模式安装时)。
    • Windows 上的 %PROGRAMDATA%\UiPath\Logs\internal\Robot.log(当机器人以服务模式安装时)。
    • ~/.local/share/UiPath/Logs/internal/Robot.log 在其他平台上。

驱动程序诊断日志

已将驱动程序跟踪写入 .etl 文件。
要启用驱动程序跟踪,请以管理员权限打开命令提示符,使用 cd 参数(例如 cd C:\Program Files\UiPath\Studio)访问安装目录,然后运行 UiRobot.exe --enableLowLevel 命令。
要禁用驱动程序跟踪,请以管理员权限打开命令提示符,使用 cd 参数(例如 cd C:\Program Files\UiPath\Studio)访问安装目录,然后运行 UiRobot.exe --disableLowLevel 命令。
备注:

我们建议仅在调查问题时启用“低级别追踪”,并在调查会话结束后将其禁用。

此外,仅在禁用该功能后,才会生成包含追踪信息的 .etl 文件。

无需重新启动机器人即可使更改生效。

此页面是否有帮助?

获取您需要的帮助
了解 RPA - 自动化课程
UiPath Community 论坛
Uipath 白色徽标
信任与安全
© 2005-2024 UiPath. All rights reserved.