new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Temporal · Develop · all subjects

observability/logging

20 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Logging from Workflows using Workflow.Logger

Log from a Workflow using Workflow.Logger, which is an instance of .NET's ILogger. Example: Workflow.Logger.LogInformation("Given name: {Name}", name);

LoggerFactory configuration with console logging

The LoggerFactory can be set in the client. The following example shows logging on the console and sets the level to Information: ```csharp var client = await TemporalClient.ConnectAsync(new("localhost:7233") { LoggerFactory = LoggerFactory.Create(builder => builder. AddSimpleConsole(options => options.TimestampFormat = "[HH:mm:ss] "). SetMinimumLevel(LogLevel.Information)), }); ```

Temporal SDK logging levels and defaults

Logging in .NET uses the standard logging APIs and supports log levels from .NET's LogLevel documentation. The Temporal SDK core normally uses WARN as its default logging level. During development or troubleshooting, debug or trace might be used. In production, info or warn are used to avoid excessive log volume.

Use workflow.GetLogger for logging in Workflows

Use workflow.GetLogger(ctx) instead of the standard log package or fmt.Println. The SDK logger skips log messages during replay to avoid duplicates.

Example: Logging in a Workflow

func MyWorkflow(ctx workflow.Context, name string) (string, error) { logger := workflow.GetLogger(ctx) logger.Info("Starting workflow", "name", name) // ... } This shows how to use workflow.GetLogger to log messages in a Workflow without causing duplicates during replay.

Workflow.getLogger for logging in Java SDK

To get a standard slf4j logger in Workflow code, use the Workflow.getLogger(Class) method. Example: private static final Logger logger = Workflow.getLogger(DynamicDslWorkflow.class);

Logs in replay mode in Java SDK

Logs in replay mode are omitted by default. To enable logging in replay mode, set WorkerFactoryOptions.Builder.setEnableLoggingInReplay(boolean) to true.

Use Workflow.getLogger() for logging

Use Workflow.getLogger() instead of System.out.println or a logger you create yourself. The SDK logger skips log messages during replay to avoid duplicates.

Workflow.getLogger() example

Example of using Workflow logger: ```java public class MyWorkflowImpl implements MyWorkflow { private static final Logger logger = Workflow.getLogger(MyWorkflowImpl.class); @Override public String execute(String name) { logger.info("Starting workflow for {}", name); // ... } } ```

Workflow logging with PSR-3 logger

Use Workflow::getLogger() to get a PSR-3 compatible logger in Workflow code. The logger automatically enriches log context with the current Task Queue name. Logs in replay mode are omitted unless the enableLoggingInReplay Worker option is set to true.

PHP SDK default logger StderrLogger

The PHP SDK uses StderrLogger by default, which outputs log messages to the standard error stream. These messages are automatically captured by RoadRunner and incorporated into its logging system with the INFO level.

PSR-3 logging levels in Temporal PHP SDK

The Temporal SDK core normally uses WARN as its default logging level. Supported logging levels follow PSR-3 specification. During development or troubleshooting, debug or trace levels may be used. In production, info or warn levels are recommended to avoid excessive log volume.

Custom logger for PHP SDK Worker

You can set a custom PSR-3 compatible logger when creating a Worker by passing it to the newWorker() method. The logger parameter accepts a PSR-3 compatible logger instance.

Workflow logging example in PHP

Example of logging in a PHP Workflow: ```php use Temporal\Workflow; #[Workflow\WorkflowInterface] class MyWorkflow { #[Workflow\WorkflowMethod] public function execute(string $param): \Generator { Workflow::getLogger()->info('Workflow started', ['parameter' => $param]); // Your workflow implementation Workflow::getLogger()->info('Workflow completed'); return 'Done'; } } ```

Enable logging in replay mode for PHP Worker

To enable logging in replay mode, set the enableLoggingInReplay Worker option to true when creating a Worker using WorkerOptions::new()->withEnableLoggingInReplay(true).

Log from Workflow using Python SDK

Use Python's standard logging module in Workflows. Import logging and call logging.basicConfig() to set the logging level (e.g., logging.INFO). In your Workflow, access workflow.logger to log messages. The Temporal SDK core normally uses WARN as its default logging level.

Python Workflow logging example

import logging from temporalio import workflow logging.basicConfig(level=logging.INFO) @workflow.defn class GreetingWorkflow: def __init__(self) -> None: self._greeting = "<no greeting>" @workflow.run async def run(self, name: str) -> None: workflow.logger.info("Workflow input parameter: %s" % name) self._greeting = f"Hello, {name}!"

Configure logger when connecting Ruby client

The `logger` can be set when connecting a client using Ruby's standard `Logger`. Example: `Temporalio::Client.connect('localhost:7233', 'my-namespace', logger: Logger.new($stdout, level: Logger::INFO))`. The Temporal SDK core normally uses `WARN` as its default logging level.

Log from a Workflow in Ruby

Log from a Workflow using `Temporalio::Workflow.logger`, which is a special instance of Ruby's `Logger` that appends workflow details to every log and does not log during replay. Example: `Temporalio::Workflow.logger.info("Some log #{some_value}")`

Log from an Activity in Ruby

Log from an Activity using `Temporalio::Activity::Context.current.logger`, which is a special instance of Ruby's `Logger` that appends Activity details to every log. Example: `Temporalio::Activity::Context.current.logger.info("Some log #{some_value}")`

Give your agent this brain