{"by":"theogravity","descendants":26,"id":42606454,"kids":[42606937,42608049,42607255,42607220,42610137],"score":56,"text":"As a longtime TypeScript&#x2F;Node.js developer, I&#x27;ve often faced challenges with logging—choosing, using, and maintaining the right logger for various projects. While most loggers offer the usual methods like &quot;info&quot;, &quot;warn&quot;, and &quot;error&quot;, they vary significantly in how they handle structured metadata or Error objects. This can lead to ad-hoc solutions, like serializing errors or writing custom pipelines, just to get logs formatted correctly.<p>I built LogLayer to address these pain points by introducing a fluid, expressive API. With methods like &quot;withMetadata&quot; and &quot;withError&quot;, LogLayer separates object injection from the log message itself, making your logging code both cleaner and more maintainable.<p>Logs are processed through a LogLayer Transport, which acts as an adapter for your preferred logging library. This design offers several key advantages:<p>- Multi-Transport Support: Send logs to multiple destinations (e.g., DataDog and New Relic) simultaneously. I&#x27;ve personally used this feature to ship logs directly to DataDog without relying on their APM package or sidecars.<p>- Easy Logger Swapping: If you’ve ever used Pino with Next.js, you might have encountered issues where it doesn’t work out of the box after a production build without webpack hacks. With LogLayer, you can swap in a better-suited library without touching your logging code.<p>I spent a good few months on and off and used my winter break to launch version 5 of LogLayer, and also created the documentation using Vitepress.<p>LogLayer has been battle-tested in production at Airtop (<a href=\"https:&#x2F;&#x2F;airtop.ai\" rel=\"nofollow\">https:&#x2F;&#x2F;airtop.ai</a>), where it’s been an integral part of our systems for years (we were running as Switchboard for almost four years and pivoted late last year).<p>(Disclaimer: I work at Airtop, but LogLayer is not sponsored &#x2F; affiliated with them.)","time":1736124744,"title":"Show HN: LogLayer – Unified logger that routes logs to various logging libraries","type":"story","url":"https://loglayer.dev/"}