Robot Logs directly to ElasticSearch NLog target

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 :wink:

1 Like

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="" xmlns:xsi="" 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 -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="" xmlns:xsi="">
    <add assembly="NLog.Targets.ElasticSearch"/>
  <variable name="WorkflowLoggingDirectory" value="${specialfolder:folder=LocalApplicationData}/UiPath/Logs" />
    <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="" 
    <logger name="WorkflowLogging" minlevel="Info" writeTo="robotElastic,WorkflowLogFiles" final="true" />


And It finally works :slight_smile:


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.