Simple Node Logger is a multi-level logging library for Node.js, providing robust support for console, file, and rolling file appenders. Currently at version 21.8.12, it offers flexible configuration options including custom timestamp formats, dynamic log level changes (trace, debug, info, warn, error, fatal), and the ability to integrate with process error events. Its key differentiators include a modular log manager for creating multiple loggers and appenders, support for domain and category columns in logs, and built-in statistics tracking for log statements. The library is designed for ease of use in small to large production environments, focusing on core logging functionalities without excessive complexity, and ships with TypeScript definitions for improved developer experience. While the documentation primarily shows CommonJS `require` patterns, it includes type definitions, suggesting compatibility with modern TypeScript setups.
npm install simple-node-loggerVerified import paths — ran on the pinned version, not inferred.
Demonstrates setting up a rolling file logger with a custom timestamp format, setting the log level at runtime, and logging messages at various levels.
Ensure the target log directory exists before initializing the logger, e.g., `require('fs').mkdirSync('./logs', { recursive: true });`For TypeScript projects, set `"esModuleInterop": true` in `tsconfig.json` or use `import SimpleNodeLogger = require('simple-node-logger');` for CommonJS-style imports. For pure ESM environments, `import * as SimpleNodeLogger from 'simple-node-logger';` may be necessary.Verify that `setLevel` is called on the intended logger instance (e.g., `log.setLevel('warn')`) or on the `LogManager` if managing multiple loggers centrally.Grant write permissions to the user running the Node.js process for the log directory, or change the `logDirectory`/`logFilePath` to a writable location. On Linux/macOS, use `chmod -R 775 /path/to/log`.
Create the log directory before initializing the logger. Example: `require('fs').mkdirSync('/path/to/nonexistent/directory', { recursive: true });`Enable `esModuleInterop: true` in `tsconfig.json`. Alternatively, use `import * as SimpleNodeLogger from 'simple-node-logger';` and then `SimpleNodeLogger.createSimpleLogger();`, or stick to the CommonJS `const { createSimpleLogger } = require('simple-node-logger');` if not in a pure ESM environment.No dependency data recorded yet.