Write trace log from custom activity

studio
logs

#1

I am creating a custom activity.
The activity is working fine.
But i need to have some logs generated when the activity is executing.
how do I achieve that?
I need some trace and some info logs to be written when the activity executes.


#2

You could use the Log message activity to write logs before or after the activity. Within the custom activity itself I dont think we have the ability to log the messages.


#3

hey @akhi_s27

If you are not able to generate a log from Log activity with custom activities then you can also use writeline activity. it will be shown in the log as well.

May be to check that activity is executing or not add writeline before this activity i.e. something like this “activity started” and add one more after that custom activity. if your activity is working well then you will be able to see the last one log written in writeline and what others you can do is if your custom activity is generating any exception then use try-catch as well.

Let me know, if this helps or not?

Regards…!!


#4

(Below is a semi-speculation answer)

Since UiPath uses NLog, you might be able to reference it’s assembly dynamically and use GetLogger,
or
Use Console.Write/WriteLine - while not ideal, it should be intercepted I think (not tested),
or
Add NLog or equivalent to your assembly and create your logs from there (you could also try pointing it to UiPath’s NLog.config, not sure if it’ll work though).

Regards.


#5

thanks for directing me towards NLog.
i’ll try the Console.writeline.

and where do i get the NLog.config for uipath?


#6

It’s in the installation folder for Professional Edition, don’t know about Community.


#7

NLog.Config is located in C:\Users\mihai\AppData\Local\UiPath\app-xxxx.z.yyy but it will get change with any subsequent update.