automation-suite
2023.10
false
UiPath logo, featuring letters U and I in white
Linux 版 Automation Suite 安装指南
Last updated 2024年12月3日

配置 NLog

添加 NLog 扩展程序

Orchestrator 默认加载以下扩展程序,因此您无需将其包含在文件夹或 NLog 配置中:

  • NLog.Targets.ElasticSearch

  • UiPath.Orchestrator.Logs.Elasticsearch

  • Microsoft.ApplicationInsights.NLogTarget

  • NLog.Extensions.AzureEventHub

在此设置中,只能使用与 Linux 兼容的扩展程序,因此请确保您选择的 NLog 扩展程序遵守此规则。

要使扩展程序可用,必须将其上传到集群存储。Orchestrator 配置程序工具可以通过 -n|--nlog-extensions-folder 参数执行此操作:
./orchestrator-configurator.sh -n nlogextensions./orchestrator-configurator.sh -n nlogextensions
如果在集群级别使用外部存储配置,则必须通过包含 --use-external-storage 参数来指明这一点。

高级 NLog 配置

  1. 创建包含以下标准部分的 nlog.config.json 文件:扩展程序、目标和规则。
    扩展程序部分是一个项目数组,通过 assemblyFile 和程序集的路径指定扩展程序集。
    如果加载了自定义 nlog 插件(如添加 NLog 扩展程序部分中所述),则将在 extensions 部分中引用这些插件。
  2. nlog.config.json 文件中配置目标和规则。
  3. 使用 Orchestrator 配置程序工具应用 nlog.config.json 文件:
    ./orchestrator-configurator.sh -l nlog.custom.config./orchestrator-configurator.sh -l nlog.custom.config
    将日志写入 Azure Blob 的 nlog.config.json 文件示例:
    {   "NLog": {
            "extensions": [
                { "assemblyFile": "NLog.Extensions.AzureBlobStorage.dll" }
            ],
            "targets": {
                "azureBlob": {
                    "type": "AzureBlobStorage",
                    "connectionString": "DefaultEndpointsProtocol=https;AccountName=test;AccountKey=key;EndpointSuffix=core.windows.net",
                    "container": "orchestratorlogs",
                    "blobName": "${date:format=yyyy-MM-dd hh.mm}",
                    "layout": {
                      "type": "JsonLayout",
                      "includeAllProperties": true,
                      "Attributes": [
                        {"name": "ts","layout": "${longdate}"},
                        {"name": "level","layout": "${level:upperCase=true}"},
                        {"name": "logger","layout": "${logger}"},
                        {"name": "message","layout": "${message}"},
                        {"name": "exception","layout": "${onexception:${ui-pretty-exception}}"}
                      ]
                    }
                }
            },
            "rules": { "70_Final": { "writeTo": "stdout,azureBlob" } }
        }
    }{   "NLog": {
            "extensions": [
                { "assemblyFile": "NLog.Extensions.AzureBlobStorage.dll" }
            ],
            "targets": {
                "azureBlob": {
                    "type": "AzureBlobStorage",
                    "connectionString": "DefaultEndpointsProtocol=https;AccountName=test;AccountKey=key;EndpointSuffix=core.windows.net",
                    "container": "orchestratorlogs",
                    "blobName": "${date:format=yyyy-MM-dd hh.mm}",
                    "layout": {
                      "type": "JsonLayout",
                      "includeAllProperties": true,
                      "Attributes": [
                        {"name": "ts","layout": "${longdate}"},
                        {"name": "level","layout": "${level:upperCase=true}"},
                        {"name": "logger","layout": "${logger}"},
                        {"name": "message","layout": "${message}"},
                        {"name": "exception","layout": "${onexception:${ui-pretty-exception}}"}
                      ]
                    }
                }
            },
            "rules": { "70_Final": { "writeTo": "stdout,azureBlob" } }
        }
    }
    将机器人日志写入 Splunk 的 nlog.config.json 文件示例:
    {
        "Nlog": {
            "extensions": [
                { "assemblyFile": "NLog.Targets.Splunk.dll" },
                { "assembly": "UiPath.Orchestrator.Logs.DatabaseBulk.NLogTarget" }
            ],
            "targets": {
                "Splunk": {
                    "type": "BufferingWrapper",
                    "flushTimeout": 5000,
                    "target": {
                        "type": "SplunkHttpEventCollector",
                        "serverUrl": "http://splunk.example.com",
                        "token": "splunk-token",
                        "channel": "",
                        "source": "${logger}",
                        "sourceType": "_json",
                        "index": "uipath",
                        "retriesOnError": "0",
                        "batchSizeBytes": "0",
                        "batchSizeCount": "0",
                        "includeEventProperties": "true",
                        "includePositionalParameters": "true",
                        "includeMdlc": "true",
                        "maxConnectionsPerServer": "10",
                        "ignoreSslErrors": "false",
                        "useProxy": "false",
                        "proxyUrl": "",
                        "proxyUser": "",
                        "proxyPassword": ""
                    }
                }
            },
            "rules": {
                "20_Robot_Primary": { "writeTo": "Splunk,database,insightsRobotLogs" }
            }
        }
    }{
        "Nlog": {
            "extensions": [
                { "assemblyFile": "NLog.Targets.Splunk.dll" },
                { "assembly": "UiPath.Orchestrator.Logs.DatabaseBulk.NLogTarget" }
            ],
            "targets": {
                "Splunk": {
                    "type": "BufferingWrapper",
                    "flushTimeout": 5000,
                    "target": {
                        "type": "SplunkHttpEventCollector",
                        "serverUrl": "http://splunk.example.com",
                        "token": "splunk-token",
                        "channel": "",
                        "source": "${logger}",
                        "sourceType": "_json",
                        "index": "uipath",
                        "retriesOnError": "0",
                        "batchSizeBytes": "0",
                        "batchSizeCount": "0",
                        "includeEventProperties": "true",
                        "includePositionalParameters": "true",
                        "includeMdlc": "true",
                        "maxConnectionsPerServer": "10",
                        "ignoreSslErrors": "false",
                        "useProxy": "false",
                        "proxyUrl": "",
                        "proxyUser": "",
                        "proxyPassword": ""
                    }
                }
            },
            "rules": {
                "20_Robot_Primary": { "writeTo": "Splunk,database,insightsRobotLogs" }
            }
        }
    }
  • 添加 NLog 扩展程序
  • 高级 NLog 配置

此页面有帮助吗?

获取您需要的帮助
了解 RPA - 自动化课程
UiPath Community 论坛
Uipath Logo White
信任与安全
© 2005-2024 UiPath。保留所有权利。