Duplicate logging in your production environment can occur if both the default logger and your cu...

When I'm using HttpMiddleware.logger, I'm seeing my logs show up twice. Once using Effect's built-in logger, and once using my custom logger. Is there a way to prevent it from logging twice? I use Logger.pretty in my dev environment, but I use a custom ProdLogger with Logger.replace(Logger.defaultLogger, ProdLogger) in my prod environment and I'm seeing duplicates only in production.

For example, I might see a log like this

[02:35:17.371] INFO (#15185) http.span.422=0ms: Sent HTTP response
  http.status: 200
  http.method: GET
  http.url: /health/ping
{"level":"info","time":1749609317371,"pid":1,"hostname":"backend-679c47dddd-7ljkg","message":"Sent HTTP response","logLevel":"INFO","timestamp":"2025-06-11T02:35:17.371Z","annotations":{"http.status":200,"http.method":"GET","http.url":"/health/ping"},"spans":{"http.span.422":0},"fiberId":"#15185","severity_number":9,"severity_text":"INFO"}


The second json log is my logger, and I think the first log is Effect's logger.

My HttpApi definition is this

HttpApiBuilder.serve(HttpMiddleware.logger).pipe(
  Layer.provide(AppApiLive),
  Layer.provide(HttpApiBuilder.middlewareCors()),
  HttpServer.withLogAddress,
  Layer.provide(AppLayer),
  Layer.provide(NodeHttpServer.layer(createServer, { port: baseGlobalConfigUnsafe.PORT }))
);


AppLayer contains the logger.
Was this page helpful?