Registry / devops / log4js-rest

log4js-rest

JSON →
library1.2.1jsnpmunverified

Optional REST appender for log4js-node that sends log events to a REST API endpoint. Version 1.2.1 is stable with no recent updates. Supports min/max level filtering and environment metadata. Integrates with the log4js logging framework. TypeScript types included.

npm install log4js-rest
INSTALL
IMPORT
SIG · LOG4JS-REST
L
log4js-rest
devopsjavascriptv1.2.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Log4JsRestAppender
import { Log4JsRestAppender } from 'log4js-rest'
import Log4JsRestAppender from 'log4js-rest'
Named export only; default import will fail.
log4js
import * as log4js from 'log4js'
const log4js = require('log4js')
ESM import style recommended for TypeScript; CJS require works but lacks types.
os
import * as os from 'os'
Used for environment metadata in configuration, not a direct dependency of log4js-rest.

Configures log4js with a REST appender, sending WARN to FATAL logs to a custom API endpoint.

import * as log4js from 'log4js'; import { Log4JsRestAppender } from 'log4js-rest'; import * as os from 'os'; log4js.configure({ appenders: { restAppender: { type: Log4JsRestAppender, url: process.env.REST_LOG_URL ?? 'http://localhost:3000/log', appName: 'myApp', level: 'INFO', env: { host: os.hostname(), type: os.platform() }, minLevel: log4js.levels.WARN, maxLevel: log4js.levels.FATAL, collectionName: 'myLogs' } }, categories: { default: { appenders: ['restAppender'], level: 'DEBUG' } } }); const logger = log4js.getLogger(); logger.warn('App start');
Debug
Known issues
gotchaNamed import { Log4JsRestAppender } is required; default import does not work.
fix
Use import { Log4JsRestAppender } from 'log4js-rest'.
affects: >=1.0.0
gotchaThe type field must reference the class constructor, not a string.
fix
Use type: Log4JsRestAppender (the imported class), not a string like 'rest'.
affects: >=1.0.0
Errors
Common errors & fixes
Module not found: Can't resolve 'log4js-rest'
Package not installed
fix
Run 'npm install log4js-rest'
TypeError: log4js.configure is not a function
Incorrect log4js import (e.g., default import instead of namespace import)
fix
Use 'import * as log4js from 'log4js'
Error: Appender type must be a function, not a string
Using string type instead of class reference in configure
fix
Set type to the imported Log4JsRestAppender class instance
Upgrade
Version history
1.2.1latest on npm
Audit
Dependencies
log4jsrequiredCore logging framework required for appender functionality
Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources
log4js-rest — npm install log4js-rest · libregistry