Custom Logging - LogLevel Type

Hello everyone,

i am building my own Library for logging and i want to pass in_argument with LogLevel, which can be filled in activity Log Message in LogLevel field.

But everytime, when i open the Expression Editor in Log Message, it throws this error and i cant pass anything with my own argument.

Is it possible to do my own logging with passing argument f.e. in_loggingLevel = “Error” or its not possible?

Is it another way how to log something in vb.net without using log messages or write line activities?

Thanks !

Hello,

I think you have to put the dependencies before LogLevel, so it will be like : uiPath.Core.activities.LogLevel.Fatal
Or another library if it’s not in this one, if it doesn’t work i’m cluecless, sorry

HI @janlemon

Can you give more details like which version of studio activities and how you are trying to pass and where you are using it?

Because with current info I see no issue and I generally pass this sometimes when needed but never faced any issue as such

Did you give an argument or variable name also as loglevel?

cheers

It is possible in libraries developed in activity creator in visual studio.
I use UiPath.Robot.Activities.Api dependency:

var apiRuntime = context.GetExtension<IExecutorRuntime>();
apiRuntime.LogMessage(new LogMessage
{
   EventType = TraceEventType.Error,
   Message = "my message"
});
1 Like

I was trying to Set the Type of argument as LogLevel, but it doesn´t work.

At the screensho it´s a default value, it´s throwing the error everytime when i open the expression editor, these values are default values (that LogLevel.Fatal is default logLevel of Log Message)

Studio is 2022.10.1

So its nessesary to do it in VS and than import as a activity to the Studio?

The goal is to have 2 arguments:

  1. in_logMessage
  2. in_logLevel

We are using logging, where we need to log also the name of workflow, so because i dont want to put everytime to my log messages this string Jobs.workflowname +": " + logMessage, i just want to make a new logMessage where i can just put logLevel and String with arguments :slight_smile:

I don’t know how we can implement this method in invoke code, because we need activity context object. In visual studio activity creator you can also get and use current workflow file name or path. What is more LogLevel can be implemented there as dropdown in property panel.

You’ve already been given the correct answer above. Read the validation message, ‘LogLevel’ is ambiguous. This means it can find an a Loglevel enum or class etc in multiple namespaces so the code doesn’t know which one you want to use, you need to fully qualify the expression by putting the full namespace.

As Jon_Smith mentioned, we have 2 types with the same name:
image
You need to use full name UiPath.Core.Activities.LogLevel