Skip to content

Logger.consoleJson does not format Error correctly #8144

Description

@StefanWerW

What version of Effect is running?

4.0.0-rc.112

What steps can reproduce the bug?

The Logger.consoleJson logger does not log correctly Errors that are not Data.TaggedError. The error message is not included in the logs.
Minimal reproducible example: https://effect.website/play#a737a4f170c5

OR the code:

import { NodeRuntime } from "@effect/platform-node"
import { Effect, Logger } from "effect"

const program = Effect.gen(function*() {
  yield* Effect.fail(new Error("This message is currently not parsed"))
}).pipe(
  Effect.tapError(Effect.logError),
  Effect.catch(() => Effect.succeed(""))
)

NodeRuntime.runMain(program.pipe(
  Effect.provide(Logger.layer([Logger.consoleJson]))
  //Effect.provide(Logger.layer([Logger.consoleStructured]))
))

{"message":{},"level":"ERROR","timestamp":"2026-09-09T11:07:49.837Z","annotations":{},"spans":{},"fiberId":"#2"}

What is the expected behavior?

To have something similar to Logger.formatStructured

{"message":"Error: This message is currently not parsed","level":"ERROR","timestamp":"2026-09-09T11:00:20.270Z","annotations":{},"spans":{},"fiberId":"#2"}

What do you see instead?

{"message":{},"level":"ERROR","timestamp":"2026-09-09T11:00:20.270Z","annotations":{},"spans":{},"fiberId":"#2"}

Additional information

I think the problem is in Formatter.formatJson, maybe we need a epecial case for isntaceof Error.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions