New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

winston-winlog4

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

winston-winlog4

Windows Event Log logger for the node.js Winston module.

  • 3.1.0
  • latest
  • Source
  • npm
  • Socket score

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

winston-winlog4

winston-winlog4 is a custom transport for Winston, designed to log messages to the Windows Event Log. It is a fork of winston-winlog2 and uses the node-eventlog library to write structured log data directly to the Windows Event Viewer. This transport is ideal for applications running on Windows where centralized, system-wide logging is beneficial.

Installation

Install via npm:

npm install winston-winlog4

Usage

To use winston-winlog4, import and add it to your Winston logger's transports.

import winston from 'winston';
import EventLogTransport from 'winston-winlog4';

const logger = winston.createLogger({
  transports: [
    new EventLogTransport({
      source: 'MyApplicationName', // Optional, defaults to 'node'
      level: 'info'                // Set the minimum level for this transport
    })
  ]
});

// Example logs
logger.info('Application started');
logger.warn('Potential issue detected');
logger.error('An error occurred');

This will log messages to the Windows Event Log under the specified source name, with levels info, warn, or error.

Options

The EventLogTransport class accepts the following options:

OptionTypeDescriptionDefault
sourcestringThe source name shown in the Event Viewernode
levelstringThe minimum level of messages to log (info, warn, error)info

Features

  • Direct Windows Event Logging: Logs are sent to the Windows Event Log, accessible in the Windows Event Viewer.
  • JSON Metadata Support: Includes metadata with each log, formatted as a JSON string, for easier log analysis.
  • Supported Levels: Only logs at info, warn, or error levels are supported to match typical Windows Event Viewer log levels.

Handling Metadata

Metadata is supported in the info parameter of the log function, where it is converted to a JSON string using flatted. If metadata cannot be parsed, it falls back gracefully with an error message. Any newlines in the log messages are removed for compatibility with the Event Viewer.

Development

To clone the repository and contribute:

git clone https://github.com/matteogheza/winston-winlog4
cd winston-winlog4
npm install

License

This module is licensed under the MIT License. See the LICENSE file for details.

Keywords

FAQs

Package last updated on 06 Nov 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