Unable to Add Log fields in The custom activity for Log

using System;
using System.Activities;
using System.Collections.Generic;
using System.Diagnostics;
using System.ComponentModel;
using System.IO;
using UiPath.Core.Activities;

namespace CustomLogging
public class CustomLogActivity : CodeActivity
// Methods
[Category(“Log”), RequiredArgument]
public InArgument LogCode { get; set; }
public InArgument ExtraData { get; set; }
public InArgument Message { get; set; }

    public CustomLogActivity()
        this.ExtraData = "";
        this.Message = "";
    protected override void Execute(CodeActivityContext context)
        string machineNameValue = Environment.MachineName;
        InArgument<string> machineName = new InArgument<string>();
        machineName = machineNameValue;
        Dictionary<string, InArgument> NewFieldsDictionary = new Dictionary<string, InArgument>
            { "LogCode", this.LogCode },
            { "ExtraData", this.ExtraData},
            { "MachineName", machineName }
        List<InArgument<string>> NewFieldsList = new List<InArgument<string>>

        AddLogFields addLog = new AddLogFields() { Fields = NewFieldsDictionary };

        WorkflowInvoker activity = new WorkflowInvoker(addLog);


        LogMessage customLog = new LogMessage
            Level = CurentLogLevel.Info,
            Message = this.Message

        activity = new WorkflowInvoker(customLog);
        RemoveLogFields removeLog = new RemoveLogFields() { Fields = NewFieldsList };
        activity = new WorkflowInvoker(removeLog);




1 Like

@ovi I hope you could help me with this.
this custom activity runs without error but I dont see the additional fields in the the log message.
I am not sure why the add log fields activity not working for me.

Below is the output of Log message.
“message”: “test message”,
“level”: “Information”,
“timeStamp”: “12:33:14”,
“processVersion”: “1.0.6797.29120”,
“fileName”: “Main”,
“jobId”: “a5aafbf3-31de-48f3-9d79-b7e6ef8b064f”,
“robotName”: “Rohan_Laptop”

1 Like

Hey Rohan,

I need to investigate for your custom activity. But why don’t you use the Add log fields activity?

This is what I get when running the Add log fields activity:
13:19:47.1039 Info {
“message”:“add log fields execution ended”,
“processName”:“add log fields”,
“robotName”:“Forum Buddy”,

Hi @ovi

So basically in uipath we have to use three activities to do this
Add LogFields → Log Message → Remove Log Fields

Moreover for my project requirement I am supposed to make a custom code base activity for a custom logging mechanism where I want to do the work of these three activities into a single custom activity.

Hi @ovi

Did you find anything on this ?


I have a question Rohan, why do we need Remove Log Fields , any specific reason.

Can you share sample xaml please

Hi @rohan_garg Did you find the solution for this?

Hi @Prakshi_Tyagi,

The rollover of the Uipath Library functionality did help in this but Now I am looking out for the ways to actually get the log fields and their values using some program during runtime, instead of writing them to orchestrator using log activity.

Fields/Values required are below:-
“processName”:“add log fields”,
“robotName”:“Forum Buddy”