Robot Execution Logs, NLog Target Customization

Hello Dear Forum Members,

I want to differentiate between an attended and unattended robot simply based on the execution logs generated by the robots. I added a custom log field called RobotType: Attended in automations that use attended robots and RobotType: Unattended in automations that use unattended robots.

Afterwards, I updated the NLog.config file as follows with a new rule and target:
<rules> <logger name="WorkflowLogging" writeTo="WorkflowLogFilesAttended" final="true"> <filters> <when condition="contains('${message}','Attended')" action="Log"/> </filters> </logger> </rules>

and a new target as follows for the above rule:
<target type="File" name="WorkflowLogFilesAttended" fileName="${WorkflowLoggingDirectory}/${shortdate}_Execution_Attended.log" layout="${message}" concurrentWrites="true" encoding="utf-8" writeBom="true" />

The problem is that this target is always being logged even if the when condition is not true. Not sure what I am doing wrong.

Best.

Hi @haider8645

Just to get the obvious out of the way, did you restart the robot service after making the changes to the NLog.config file? :slight_smile:

@loginerror

I did restart it but I thought the NLog.config changes do not require a restart of the Robot service. Any idea what I could try next? :slight_smile:

Indeed, I have misread the note from the support documentation file, my bad :slight_smile:
image

I did not really try this yet, so I would suggest you to step back and debug in small steps.

My first thought would be to try and filter by a standard log field. Maybe the additional one cannot be processed (it’s just a thought, I don’t actually know just yet if that is the case).

Also, I would try to simplify the filter condition to try to see if that will help.

@loginerror

The filter condition at the moment is when condition="contains('${message}','Attended'. I find it as a very simple condition, it just looks if the message from Robot log contains the string Attended. But the thing is having this filter or not does not make any difference, everything is logged regardless of this filter.

What do you mean by standard log field?

It might be that filtering is not supported :frowning:

As to the standard log field, I meant the ones that are there by default… You said that you

added a custom log field called RobotType: Attended

How about trying to filter by a default field and see if it will work?

@loginerror

Hey, yes I just tried the when contain with a standard logged robotName but the condition does not have any effect whatsoever on the logging… :frowning:

@haider8645 did you find any solution on this? I guess as @loginerror mentioned filtering might not be supported.

@ronlobo Hey, no solution was found. The only way to using NLog filters is to wait for UiPath to update to the new NLog version. Others ways to isolate logs are:

  • Use Organization Units function and have separate OUs for attended and unattended robots. Logs are isolated among organization units.
  • Create a Custom Log Field in each RPA solution, call it for example “RobotType” that can log either Attended or Unattended. You can then filter logs in Elasticsearch, Splunk or any other Log Management System based on this “RobotType” parameter.

Hope it helps.

Best.

1 Like

@haider8645 thank you so much for your valuable reply