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');
Errors
Common errors & fixes
Module not found: Can't resolve 'log4js-rest'
Package not installed
fixRun 'npm install log4js-rest'
TypeError: log4js.configure is not a function
Incorrect log4js import (e.g., default import instead of namespace import)
fixUse 'import * as log4js from 'log4js'
Error: Appender type must be a function, not a string
Using string type instead of class reference in configure
fixSet type to the imported Log4JsRestAppender class instance
Audit
Dependencies
log4jsrequiredCore logging framework required for appender functionality