How to log inside "Invoke code" activity?

Hi,

I’m wondering whether it is possible to log messages inside “Invoke code” activity in the same manner as the “Log message” activity does? Is there for example a particular namespace that contains the logging methods so that I could use them inside “Invoke code” activity? This would be useful so that I could get more fine-tuned information about what happens inside the “Invoke code” activity.

5 Likes

You could try to use Console.WriteLine ?
It should basically log Trace level messages. This is by far the easiest way of doing it that I can think of.

uipath.Core.Activities.LogMessage()

5 Likes

Thank you for your reply. I have been using Console.WriteLine method so far but the problem with this is that log messages don’t appear in Orchestrator even though I specify the log level as Trace.

Thank you! This seems to do the trick. Using this approach I managed to get the logging working with the following piece of code:

Dim logMessage As UiPath.Core.Activities.LogMessage = New UiPath.Core.Activities.LogMessage()
logMessage.Level = UiPath.Core.Activities.CurentLogLevel.Error
logMessage.Message = "Hello World!"
Dim logInvoker As WorkflowInvoker = New WorkflowInvoker(logMessage)
logInvoker.Invoke()
12 Likes

Gr8! Yes we need to invoke the logmessage to get this class work in invoke code

You started a Brilliant topic my friend. Hats off to you @Ledorin and @Atrimal for providing us all with this valuable piece of Info.

How about in C# ?

I am creating a Custom Activity and use Console.writeline so far I watch the value from output panel in studio but I can not see in the Orchestrator log.

please some a good man suggest me how to do it.

thanks in advance.

Hi forum team.

I was trying to find how to log messages from invoke codes and I came across this thread.
Unfortunately, I believe this no longer works on newer versions of UiPath. Could you provide the current solution or reopen the following thread?

Best regards,
Pedro.

1 Like

Hi @Mombas

I made your post public and moved it to the topic that you’ve mentioned that is now opened to continue this discussion :slight_smile:

1 Like

Even am facing the same Issue

May i know how can we convert String to
System.activities.InArgument(Of system.Object)

Regards
Sanjay

You can always use message boxes for debugging. Just type before/after line you want to check:

UiPath.NativeMessageBox.ShowInfo(“Your message” + youCanUseVariables.toString)

Hi Ledorin,

I was trying to call this activity as per you suggested, though I got the Object Null exception.
I have attached the workflow and the screenshot I am getting while executing the workflow.
Need your help.

CustomLogging.xaml (6.2 KB)

Hi, im having the same issue, did you find a solution for this?

Hi, anyone has any news on this topic?

Im re-taking it time to time and its becoming one of the top ranked hour-wasted topics in my team… Still no idea about which Object we have to send here…

Hug

maybe this is sufficient for the needs
grafik
grafik

As mentioned above Console.WriteLine was working

Overcoming the issue with the InArgument /Conversion we can do:

grafik
grafik

Code:

Dim wl As System.Activities.Statements.WriteLine = New System.Activities.Statements.WriteLine()
wl.Text = New InArgument(Of String)("Hello From WriteLine")
Dim res As IDictionary(Of String, Object) = WorkflowInvoker.Invoke(wl)

Unfortunatly the same was not working on the first hit with logMessage. But the LogMessage Activity was created with the Input Arguments for LogLevel and Message in the same way and looked ok for this part

1 Like

Any solution for this in 2021?