Log Message in Invoke Code (VB.Net) activity

Hello,

I’m trying to log a message (level - Info) within the Invoke code activity.

I tried with the codes got from recent similar topics

But, I’m not able to find a solution.

Please help to find a solution, Thanks

1 Like

Hey @Jerry1

Kindly let know, What’s the issue you are facing with the existing solution suggested in the shared thread, as I can see that was marked as working solution.

Thanks
#nK

1 Like

@Jerry1

You can write as below

Hope this will help you

Thanks

1 Like

Hello Srini,

I’m trying to log the message at log levels Info and Error

Hello,

Tried with the below 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()

Error message:
Main.xaml: No compiled code to run
error BC30456: ‘CurentLogLevel’ is not a member of ‘Activities’. At line 2
error BC30311: Value of type ‘String’ cannot be converted to ‘System.Activities.InArgument(Of Object)’. At line 3

Then, made a slight change in the code
Dim logMessage As UiPath.Core.Activities.LogMessage = New UiPath.Core.Activities.LogMessage()
logMessage.Level = UiPath.Core.Activities.LogLevel.Error
logMessage.Message = New ArgumentValue(Of Object)(“Hello”)
Dim logInvoker As WorkflowInvoker = New WorkflowInvoker(logMessage)
logInvoker.Invoke()

Error Message
Invoke code: Exception has been thrown by the target of an invocation.

Could you please help me to resolve this?

1 Like

Hey @Jerry1,

This may help you.

This should serve the same purposes.

Thanks
Nithin

1 Like

Hi Nithin,

Thanks for the suggestion. But, this won’t help me.

I need to log the message in between executing the code in the ‘Invoke Code’ activity and also, the log level needs to be ‘Info’.

1 Like

So you have an invoke code, only for that you need to log some info messages in between right ?

#nK

1 Like

Yes, Correct!

1 Like

Hi, anyone got a solution maybe?
This is my code, I’m getting nullReferenceException.
I’m able to Ivnoke another activities such as WriteLine, but not LogMessage.

Dim logMessage As UiPath.Core.Activities.LogMessage = New UiPath.Core.Activities.LogMessage()
logMessage.Level = New InArgument(Of UiPath.Core.Activities.LogLevel)(UiPath.Core.Activities.LogLevel.Warn)
logMessage.Message = New InArgument(Of Object)("Hello World!")

Dim logInvoker As WorkflowInvoker = New WorkflowInvoker(logMessage)
logInvoker.Invoke()

Thanks!

No, I was facing the same issue.

Any Update or solution, I am getting object reference error with above code at invoke method ?