How to log correctly from Temporal workflows and activities

my question is about logs:
how to correctly log from WorkFlow?
how to correctly log from Activity?
talking about Java\Kotlin
please give examples if possible

Thanks,
Shai

In workflow code use the replay safe logger you can get via Workflow.getLogger. Some examples:

Workflow.getLogger(this.getClass().getName());
Workflow.getLogger(this.getClass());
Workflow.getLogger(MyWorkflowImpl.class);

In activity code you can use a logger of your choice.

thanks much!

Are these logs visible from UI (Temporal console)? I was not able to find the customized logs there. Any additional steps to emit it?

2 Likes