Logging in temporal workflow & Activities

What’s the best logging mechanism for temporal workflows & activities and other places, which can be initialized at one place & can be propagated to all places. In TypeScript.
Thank you

You can register a custom logger using Runtime.install({ logger }), as demonstrated here:

  Runtime.install({
    logger: myCustomLogger,
  });

You can then use that logger from your workflow code by using the log object provided by the @temporalio/workflow package, such as:

import { log, proxyActivities } from '@temporalio/workflow';

export async function logSampleWorkflow(): Promise<void> {
  log.info('Greeted', { ... can add extra details here ... });
}

Similarly, you can use that logger from your activities by using the Context.log object, such as:

import { Context } from '@temporalio/activity';

export async function greet(name: string): Promise<void> {
  const { log } = Context.current();
  log.info('Log from activity', { name });
}

See the complete example here.