Standardizing logging for Ontic

Usage no npm install needed!

<script type="module">
  import onticAiLogger from 'https://cdn.skypack.dev/@ontic-ai/logger';


Ontic Technologies Node Logger

A way to standardize logs for our node services.


nk-logger includes a pre-configured logger that is a Winston v3 logger and a pre-configured loggingMiddleware that a wrapper for Morgan.


Logger is configurable by 3 env vars:

NODE_ENV: sets console and file logging levels if there is not a more specific env var set.

CONSOLE_LOGGER_LEVEL: sets logging levels to be sent to the console.

FILE_LOGGER_LEVEL: sets logging levels to be written to /logs/all-logs.log.


logger should replace console.log.

  • Logs for debugging should be logger.debug.
  • Logs that are meaningful should be logger.info
  • Logs that are warning (deprecation warning, etc.) should be logger.warn
  • Handled errors can be logged with logger.error

logger will console.log any log-level given `process.env.NODE_ENV !== 'production'.

logger keeps a rotating log of logs-level "info" or greater and errors in ./logs/all-logs.log and ./logs/errors.log respectively.

Be sure to create a ./logs directory to store logs in, and add logs/* to your .gitignore


const { logger } = require('@ontic-ai/logger');

logger.info('This is an info log');
logger.warn('This is a warn log');
logger.debug('This is a debug log');
logger.silly('This is a silly log');

Logging Middleware

loggingMiddleware can be used just like "morgan middleware" for express.


const express = require('express');
const { loggingMiddleware } = require('@nontic-ai/logger');

const app = express();