Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

logger4node

Package Overview
Dependencies
Maintainers
0
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logger4node

![build](https://github.com/yog27ray/logger4node/actions/workflows/node.js.yml/badge.svg?branch=master) [![codecov](https://codecov.io/gh/yog27ray/logger4node/branch/master/graph/badge.svg)](https://codecov.io/gh/yog27ray/logger4node)

  • 1.0.32
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
213
decreased by-31.51%
Maintainers
0
Weekly downloads
 
Created
Source

build codecov

Logger for Node

logger4node is a simple and flexible logging library for Node.js applications. It allows you to log messages with different levels of severity, and you can set different severity levels for different project files

Setup:

  1. Create Application Logger.
    import { Logger4Node } from 'logger4node';
    
    const applicationLogger = new Logger4Node('Application');
    
  2. Set log pattern and default log level.
    import { LogSeverity } from 'logger4node';
    
    applicationLogger.setLogLevel(LogSeverity.ERROR);
    applicationLogger.setLogPattern('Application:*');
    
  3. Create file level logger.
    const fileLogger = applicationLogger.instance('File1');
    
  4. Log information
    fileLogger.error('This is test log');
    
    Output:
    Error: Application:File1 This is test log
    

Configuration:

  1. JSON Logs: Logging in json provide more information and is recommended for production deployments. Json logging provide time, source, request, extraData, stack.
    applicationLogger.setJsonLogging(true);
    .
    .
    .
    fileLogger.error('This is test log');
    
    Output:
    {"level":"error","time":"2024-07-01T07:07:54.877Z","className":"Application:File1","source":{"caller":"callerFunctionName","fileName":"fileName.ts","path":"file path","line":"13","column":"10"},"message":"This is test log","request":{},"extra":{},"stack":""}
    

FAQs

Package last updated on 01 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc