TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: LogLayer – Unified logger that routes logs to various logging libraries

56 点作者 theogravity4 个月前
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.)

5 条评论

seniorsassycat4 个月前
IMO until the abstract logging interface is built into the language, or standard library, we&#x27;ll keep building different log libraries and adapters between them, and shipping libraries without logging.<p>It makes me actively disinterested in these libraries. I just want some built in interface with levels, hierarchy, and structured logging
评论 #42607500 未加载
评论 #42609939 未加载
评论 #42607188 未加载
评论 #42608363 未加载
评论 #42606965 未加载
评论 #42608044 未加载
mr-karan4 个月前
Never really caught on with the idea of integrating external I&#x2F;O in something as fundamental as logging. More often that not a pull vs push approach is suited for logging. There are dozens of high performant log collectors&#x2F;aggregators who can collect, transform, and push logs to N number of stores. What’s the advantage of doing this right inside the app? (Besides maybe serverless functions?)
评论 #42608101 未加载
评论 #42608506 未加载
benpacker4 个月前
It’s frustrating that this is necessary but it definitely makes sense, and I will probably add it to several projects soon.<p>Thanks for your hard work!
评论 #42607391 未加载
verdverm4 个月前
Makes me think of the big tent philosophy of Grafana Alloy for OTEL<p>Where does log layer fit into the broader ecosystem?<p><a href="https:&#x2F;&#x2F;github.com&#x2F;grafana&#x2F;alloy">https:&#x2F;&#x2F;github.com&#x2F;grafana&#x2F;alloy</a>
评论 #42607330 未加载
riwsky4 个月前
Situation: there are 14 competing JS logging APIs.<p><a href="https:&#x2F;&#x2F;xkcd.com&#x2F;927" rel="nofollow">https:&#x2F;&#x2F;xkcd.com&#x2F;927</a>