electron-log

Zero-dependency logging for Electron, Node.js, and NW.js apps with file, console, and remote transports.

Library
npm
v5.4.4
1,476 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
56 /100 Fair
Development Activity 52
Maintenance 16
Community 56
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
79 /100 Good
Architecture 78
Code Quality 76
Innovation 80
Learning Curve 82

electron-log is a logging library purpose-built for Electron applications, though it works equally well in plain Node.js and NW.js. It ships with sensible defaults out of the box: logs are written simultaneously to the console and to a per-platform log file (~/Library/Logs/{app}/main.log on macOS, %USERPROFILE%\AppData\Roaming\{app}\logs\main.log on Windows, and the XDG config path on Linux), so developers get useful diagnostics from day one without writing any transport code.

Beyond the defaults, it offers separate entry points for the main, renderer, node, and preload contexts of an Electron app, a pluggable transport system (console, file, IPC, remote HTTP), scoped loggers, log buffering for conditional verbose output, and built-in handlers for catching unhandled errors and critical Electron process events. With zero runtime dependencies and 38 contributors over nearly a decade, it has become the de facto standard logger for the Electron ecosystem.

What You Get

  • Separate, purpose-built entry points for main, renderer, node, and preload processes so each context gets correctly wired logging with zero manual IPC plumbing
  • Built-in console, file, IPC, and remote-HTTP transports, each independently configurable by log level and message format, plus support for fully custom transport functions
  • Automatic per-OS default log file locations (macOS, Windows, Linux) so file logging works immediately without configuration
  • An error handler and event logger that automatically catch unhandled exceptions, rejected promises, and critical Electron events like render-process-gone or certificate-error
  • Logging scopes and multiple named logger instances for separating output by module or subsystem, plus a buffering API for capturing verbose logs only when an operation fails
  • First-class TypeScript typings and a hook system for transforming or filtering log messages before they reach a transport

Common Use Cases

  • Capturing crash diagnostics and unhandled errors from an Electron app’s main process to a local log file for post-mortem debugging
  • Forwarding renderer-process console output to the main process log file so all application logs live in one place regardless of which process produced them
  • Sending critical errors from a deployed desktop application to a remote logging endpoint for centralized monitoring across many user machines
  • Scoping logs per subsystem (e.g., ‘updater’, ‘auth’, ‘ipc’) to make multi-module desktop applications easier to debug in production

Under The Hood

Architecture electron-log is organized around a process-aware entry point: src/index.js detects whether it is running in the renderer, main, or plain Node.js/NW.js context and requires the matching implementation (main, renderer, or node). A shared core/Logger class implements the level system, hooks, and buffering, while process-specific modules (main/index.js, node/index.js, renderer/index.js) wire up the appropriate default transports and an IPC bridge between renderer and main. This separation keeps the renderer bundle free of Node-only code (like file-system access) while still presenting one consistent log.info/warn/error API everywhere.

Tech Stack The library is plain, dependency-free JavaScript with hand-written .d.ts typings shipped alongside the JS source rather than compiled from TypeScript, keeping the published package small and dependency-free. Development tooling includes ESLint (Airbnb config), a lightweight in-house test runner (humile), and Vite/Webpack configs used only for the e2e test fixtures, not the published library itself.

Code Quality The codebase is small and modular (core/main/node/renderer split, each under a few hundred lines), with unit specs colocated under __specs__ directories next to the code they test and a working CI test/lint pipeline. Long-running maintenance since 2016 (569 commits, 38 contributors) shows staying power, though recent commit frequency has slowed to roughly one per month.

API Design The public surface is deliberately minimal: log.info(), log.warn(), etc. mirror the familiar console API, transports are configured with simple property assignment (log.transports.file.level = false), and scopes/instances follow one consistent creation pattern (log.scope(), log.create()). This low-ceremony design is a major reason it remains the most widely adopted logger in the Electron ecosystem.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers