loglevel
loglevel is a lightweight, dependency-free logging library for JavaScript that provides level-based filtering (trace, debug, info, warn, error) without the overhead of larger logging frameworks. It weighs 1.4 KB gzipped and works consistently across browsers, Node.js, and environments without a console object.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | pimterry/loglevel |
| Owner | pimterry |
| Primary language | JavaScript |
| License | MIT — OSI-approved |
| Stars | 2.7k |
| Forks | 160 |
| Open issues | 19 |
| Latest release | v1.9.2 (2024-09-06) |
| Last updated | 2025-03-20 |
| Source | https://github.com/pimterry/loglevel |
What loglevel is
A UMD module wrapping console.log methods with graceful fallbacks, level filtering, and stacktrace preservation. It includes TypeScript definitions, supports CommonJS/AMD/ES6 module systems, and automatically detects console availability. The API is minimal: five logging methods, setLevel filtering, and plugin support via method replacement.
Get the loglevel source
Clone the repository and explore it locally.
git clone https://github.com/pimterry/loglevel.gitcd loglevel# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Default level is 'warn'; explicitly call log.enableAll() or log.setLevel() at initialization if you need lower-level logs visible in development.
- Stacktrace line numbers are preserved only for direct console calls; wrapping loglevel in custom plugins will lose source attribution.
- In IE8/9, console may not exist until developer tools are opened; loglevel handles this gracefully but initial logs in those environments will be silent.
- TypeScript definitions are included; no @types package needed, but verify module syntax (default import vs. wildcard) matches your bundler/transpiler.
- No built-in way to persist logs client-side or send to a server; you must layer such behavior via custom code or a separate logging backend.
When to avoid it — and what to weigh
- Structured Logging Required — No built-in JSON logging, log correlation IDs, or structured metadata support. Incompatible with observability platforms expecting JSON-formatted logs.
- Complex Filtering or Routing Needed — Single global level filter only; cannot send different log streams to different outputs. No appender or transport system for multi-destination logging.
- High-Volume Production Telemetry — Designed for console output only. No batching, sampling, or remote log aggregation. For production observability at scale, use dedicated APM/logging services.
- Plugin-Heavy Custom Logging Pipelines — Plugin support exists but replaces internal methods, clobbering stacktraces. Not designed as a foundation for complex custom logging architectures.
License & commercial use
MIT License. Permissive OSI-approved license allowing commercial use, modification, and distribution with minimal restrictions (retain license and copyright notice).
MIT license clearly permits commercial use in closed-source products without royalty or attribution requirements (beyond retaining the license header). No known restrictions on commercial redistribution. Suitable for proprietary SaaS and enterprise applications.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Strong |
| License clarity | Clear |
| Deployment complexity | Low |
| DEV.co fit | Good |
| Assessment confidence | High |
Minimal attack surface: no network calls, no external dependencies, no eval or dynamic code execution. Logs only mirror console output. When used in browser, ensure sensitive data is never logged. No built-in encryption or obfuscation; treat logs as plain text.
Alternatives to consider
winston
Full-featured Node.js logging framework with transports, formatters, and structured logging. Larger footprint and more configuration; choose if you need multi-destination routing or JSON logs.
pino
High-performance structured JSON logging for Node.js with minimal overhead. Better for production services requiring observability platform integration; overkill for simple level-based console logging.
console-log-level
Similar lightweight alternative providing level filtering for console. Slightly smaller scope but comparable functionality; evaluate if you have specific compatibility requirements.
Build on loglevel with DEV.co software developers
loglevel integrates in seconds and weighs less than 2 KB. Perfect for frontend apps, Node.js services, and cross-platform libraries. Get started with npm install loglevel or explore the live demo.
Talk to DEV.coRelated open-source tools
Surfaced by semantic similarity across the DEV.co open-source index.
Related on DEV.co
Explore the category and the services that help you build with it.
loglevel FAQ
Will loglevel break if console is not available?
Does loglevel support sending logs to a remote server?
Can I use loglevel in a TypeScript project?
What's the performance impact of using loglevel?
Software development & web development with DEV.co
Need help beyond evaluating loglevel? DEV.co is a software development agency offering software development services and web development for teams of every size. Our software developers and web developers build custom software, web applications, APIs, and open-source observability integrations — and maintain them long-term.
Ready to Add Reliable Logging to Your JavaScript Project?
loglevel integrates in seconds and weighs less than 2 KB. Perfect for frontend apps, Node.js services, and cross-platform libraries. Get started with npm install loglevel or explore the live demo.