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

Hi,

Looking for the NLog version embedded with UIPath is a bit complicated. I didnā€™t find the information in the documentation. By the way, it could be interesting to know the product dependencies for security monitoring purpose, unless UIPath is getting in their contract the responsability to inform their customers if a vulnerability is discovered on dependencies.

Anyway, maybe UIPath embedded a version earlier to 4.6.5 of NLog, so filtering doesnā€™t work with filter tag but with condition attribute : FilteringWrapper target Ā· NLog/NLog Wiki Ā· GitHub. I will make some test with a 2018 version of the Orchestrator and keep you in touch.

Regards,
Guillaume

2 Likes

I stumbled accross this post and I think itā€™s worth updating - because itā€™s the first Google result when searching ā€œUiPath NLogā€ā€¦

(Observed on UiPath Ver 2020.4)
@rguillome you appear to be correct - ā€˜conditionā€™ is the correct keyword. web.config even uses it out of the box for some Insights functions:

<filters defaultAction="Ignore">
  <when condition="level &gt;= LogLevel.Error or ends-with('${message}',' execution ended')" action="Log" />
</filters>

Defining a filter using ā€˜conditionā€™ explained here
Writing a condition expression explained here

1 Like