Logs question

Hi,
What kind of parameters can get into logs for detailed logging?

How can I log the machine name, and the bot name into log parameters?

Is Log message is the activity to use?

Thank you,

Hi @A_Learner

There are 2 activities for logging both serve different purposes.

Please have a read on below LLM generated message to help you understand the difference better.

Feature Log Message Add Log Fields
Type Text message Structured key-value pairs (metadata)
Purpose Log a message to output/log Attach additional fields to all logs
Log Level Required (Info, Warning, etc.) No log level – just attaches data
Scope One message only Applies to all logs within scope
Use Case Write what’s happening Add context (e.g., Transaction ID)
Display in Orchestrator Yes (as message) Yes (as part of structured logs)

:magnifying_glass_tilted_left: When to Use Each?

  • Use Log Message when you want to communicate what’s happening in the process.
  • Use Add Log Fields when you want to add context (e.g., identifiers, variables) to your logs for tracking in Orchestrator or ElasticSearch.

Hope this helps.

@A_Learner

In initialisation state use Add Log Fields activity and add the machine name and bot name fields.

Now just use Log Message activity as it is we normally use it will log your message along with managing name and bot name in every log message.

2 Likes

@A_Learner

You can add any field that you want in log using add log fields..

what add log fields does it it would add the key and the data related to it in every log messages json till it comes to remove log fields

by default, message,timestamp,robotname etc will be in the log json. and message is where the log message activity message sits.. when you do add log fields , more fields or keys are added to this json and even those values are populated

so ideally when you do add log fields, it adds a fields with data you need but not in the message field

if you need in message field then in each log message you need to add them as input.Ideally log fields is a good way if you want it to be added and that can be used later in insights to group those messages together as well

Hope this helps

cheers

1 Like

Hi @A_Learner

Just try to use Environment.MachineName for machine name. And use Invoke Code to get bot name with UiPath.Executor.WorkflowRuntime.GetRobotName(). Or try. Environment.UserName

Happy Automation

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.