资料贡献的原地址https://forum.uipath.com/t/export-output-logs-automaticly/1480
效果如图
汉化版:
找到 NLog.Config文件位于UiPath安装文件夹中(通常为C: Program Files(x86) UiPath Platform)
1.
添加变量以仅获取第一条消息
<variable name="truncated_message" value="${replace:replaceWith=...:regex=true:inner=${message}:searchFor=(\,.*$)}"/>
2.将新变量添加到日志布局
layout="${time}${level}${truncated_message}
觉得复杂的小伙伴可以直接复制下面代码,覆盖到原文件
<?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" />
<variable name="truncated_message" value="${replace:replaceWith=...:regex=true:inner=${message}:searchFor=(\,.*$)}" />
<rules>
<logger name="WorkflowLogging" writeTo="WorkflowLogFiles" final="true" />
<logger minLevel="Info" writeTo="EventLog" />
</rules>
<targets>
<target type="File" name="WorkflowLogFiles" fileName="${WorkflowLoggingDirectory}/${shortdate}_Execution.log" layout="${time} ${level} ${truncated_message}" keepFileOpen="true" openFileCacheTimeout="5" concurrentWrites="true" encoding="utf-8" writeBom="true" />
<target type="EventLog" name="EventLog" layout="${processname} ${assembly-version} ${newline}${message}" source="UiPath" log="Application" />
</targets>
</nlog>