Emit traces to multiple projects simultaneously

Last updated: March 5, 2026

Summary

Create separate logger instances with setCurrent: false to emit traces to multiple projects simultaneously with distinct root spans. This prevents conflicts and ensures explicit control over which logger is used for each trace.

Applicable To

Plans: Any

Deployments: Any

Configuration Steps

Step 1: Create loggers with setCurrent: false

Initialize both loggers with setCurrent: false to prevent conflicts when using multiple loggers.

// TypeScript
import { initLogger } from "braintrust";

const primaryLogger = initLogger({
  projectName: "my-primary-project",
  apiKey: process.env.BRAINTRUST_API_KEY,
  setCurrent: false, // Prevents conflicts when using multiple loggers
});

const secondaryLogger = initLogger({
  projectName: "shared-visibility-project",
  apiKey: process.env.BRAINTRUST_API_KEY,
  setCurrent: false, // Prevents conflicts when using multiple loggers
});
# Python
from braintrust import init_logger

primary_logger = init_logger(
    project="my-primary-project",
    api_key=os.environ["BRAINTRUST_API_KEY"],
    set_current=False,  # Prevents conflicts when using multiple loggers
)

secondary_logger = init_logger(
    project="shared-visibility-project",
    api_key=os.environ["BRAINTRUST_API_KEY"],
    set_current=False,  # Prevents conflicts when using multiple loggers
)

Step 3: Log to both projects

Use each logger instance to create distinct traces in their respective projects.

// TypeScript
primaryLogger.log({ input: "request", output: "response" });
secondaryLogger.log({ input: "request", output: "response" });
# Python
primary_logger.log(input="request", output="response")
secondary_logger.log(input="request", output="response")

Use Case Example

Emit traces to both a shared service project and the consuming application's project for dual visibility without post-processing.

Relevant Link