AddLogDetails from Custom Activity

All,

I am trying to call AddLogFields from a custom activity that I created in Visual Studio; however, those fields are not visible the log message.

Both Automation Name and Process Frequency are custom fields that I want to write. My custom package/activity runs successfully.

Code Snippet
Dictionary<String, InArgument> NewFieldsDictionary = new Dictionary<String, InArgument>
{
{ “Automation Name”, this.Automation_Name},
{ “Process Frequency”,new InArgument(chosenProcessFreq)}
};

        UiPath.Core.Activities.AddLogFields addlog = new UiPath.Core.Activities.AddLogFields()
        {
            Fields = NewFieldsDictionary
        };

        WorkflowInvoker workflowInvoker = new WorkflowInvoker(addlog);
        workflowInvoker.Invoke();

Any help would be greatly appreciated.
Studio Version: 2022.

1 Like

Hey @Dwayne_Shaw

Could you please explain the purpose of adding log fields inside the custom activity ?

Thanks
#nK

Hi @Nithinkrishna,

I have a similar requirement adding additional log field named “code” which is in addition to log message. I have the same code above but it doesn’t work from a custom activity. Any idea how to make this working?

Thanks,
KP

1 Like

Hi @Dwayne_Shaw, were you able to see any luck with this?

Hi,

I was able to figure it out using a custom workflow, checking the parameters, and using the standard Add Log Details activity.

It actually has been in use across my organization for over a year now.

Best,

Dwayne

Hi, can you please explain a little more on how to do that ?

1 Like

Hey @kvkpsd

You want to add a log field into each of your log ? Is that the requirement please ?

Thanks
#nK

yes @Nithinkrishna, that is my requirement and it is required to send specific codes based on the custom activity execution.

1 Like

Hey @kvkpsd

I see the possibility in 3 ways,

  1. Use Logs endpoint to submit logs to Orchestrator

  2. Use coded automation to access log message activity in code

  3. Try using the Coded Automation supported UiPath library directly in your custom activity code

Hope this helps.

Thanks
#nK

Hi @Nithinkrishna, Thank you so much for sharing the details. If possible will you be able to share me some code/sample for above three?

Thank,
KP

1 Like