Hi all,
I am currently trying to configure some robots to write logs directly to ElasticSearch (ES).
As the robots are connected to a Cloud Orchestrator we cannot configure Orchestrator to write the logs to ES since we have to access to the Orchtrator configuration.
We are using a Google ES cloud deployment.
Manually I can post docs to ES from the machine
To configure the robot logs I edited “C:\Program Files\UiPath\Studio\NLog.config”
and followed documentation from here Robot Logs and here Home · markmcdowell/NLog.Targets.ElasticSearch Wiki · GitHub
I also modified to format of how logs are written to the user directory to ensure that the changes in the config has an effect.
But no matter how often I run the script nothing arrives at ES. And I cannot so any error logs anywhere indicating where the configuration might be off.
I also tried using a ES user instead of ApiKey but also no logs arrive.
The user is ES superuser
If anyone already successfully configured their robots to directly write to ES would be happy to learn where I went wrong
2 Likes
With some help from UiPath I figured it out. Thanks @Robert_Waldinger !
First of to see where NLog is having issues one can add a Debug Flag to help identify the issue
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" internalLogLevel="Debug" internalLogFile="C:\tmp\NLOG_DEBUG.log">
This way I could see the the ElasticSearch assembly could not be loaded
After some trial and error I figured out that Elasticsearch.Net.dll, Nest.dll and Log.Targets.ElasticSearch.dll are missing from C:\Program Files\UiPath\Studio\net461
I downloaded the assembly using the Nuget CLI NuGet Gallery | Downloads
.\nuget.exe install NLog.Targets.ElasticSearch -Version 7.7.0 -DirectDownload -Framework net461 -Verbosity normal -Source https://api.nuget.org/v3/index.json -OutputDirectory .\download_folder -NonInteractive
fetched the three .dll from their respective folders. For example:
and copied them to C:\Program Files\UiPath\Studio\net461
Now the target was working and through the debug errors I could find out that I was using the wrong format for the APIKey.
When producing a Key in ElasticCloud one gets the Keys in this format.
<?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">
<extensions>
<add assembly="NLog.Targets.ElasticSearch"/>
</extensions>
<variable name="WorkflowLoggingDirectory" value="${specialfolder:folder=LocalApplicationData}/UiPath/Logs" />
<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" />
<target xsi:type="ElasticSearch" name="robotElastic" uri="https://xxxxx.cloud.es.io"
cloudId="xxxxxxx"
apiKeyId="xxxxx"
apiKey="xxxxxx"
index="robot-${date:format=yyyy.MM}"
documentType=""
includeDefaultFields="true"
includeAllProperties="true"
layout="${message}"
requireAuth="false"
/>
</targets>
<rules>
<logger name="WorkflowLogging" minlevel="Info" writeTo="robotElastic,WorkflowLogFiles" final="true" />
</rules>
</nlog>
And It finally works
2 Likes
system
(system)
Closed
July 28, 2022, 6:34pm
3
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.