log4js
- Version 6.9.1
- Published
- 160 kB
- 5 dependencies
- Apache-2.0 license
Install
npm i log4js
yarn add log4js
pnpm add log4js
Overview
Port of Log4js to work with node.
Index
Variables
Functions
Interfaces
Type Aliases
Variables
variable levels
const levels: Levels;
Functions
function addLayout
addLayout: ( name: string, config: (a: any) => (logEvent: LoggingEvent) => any) => void;
function configure
configure: { (filename: string): Log4js; (config: Configuration): Log4js };
function connectLogger
connectLogger: ( logger: Logger, options: { format?: Format; level?: string; nolog?: any; statusRules?: any[]; context?: boolean; }) => any;
function getLogger
getLogger: (category?: string) => Logger;
function isConfigured
isConfigured: () => boolean;
function recording
recording: () => Recording;
function shutdown
shutdown: (cb?: (error?: Error) => void) => void;
Interfaces
interface AppenderModule
interface AppenderModule {}
property configure
configure: ( config?: Config, layouts?: LayoutsParam, findAppender?: () => AppenderFunction, levels?: Levels) => AppenderFunction;
interface Appenders
interface Appenders {}
Mapping of all Appenders to allow for declaration merging
Example 1
declare module 'log4js' { interface Appenders { StorageTestAppender: { type: 'storageTest'; storageMedium: 'dvd' | 'usb' | 'hdd'; }; } }
property CategoryFilterAppender
CategoryFilterAppender: CategoryFilterAppender;
property ConsoleAppender
ConsoleAppender: ConsoleAppender;
property CustomAppender
CustomAppender: CustomAppender;
property DateFileAppender
DateFileAppender: DateFileAppender;
property FileAppender
FileAppender: FileAppender;
property LogLevelFilterAppender
LogLevelFilterAppender: LogLevelFilterAppender;
property MultiFileAppender
MultiFileAppender: MultiFileAppender;
property MultiprocessAppender
MultiprocessAppender: MultiprocessAppender;
property NoLogFilterAppender
NoLogFilterAppender: NoLogFilterAppender;
property RecordingAppender
RecordingAppender: RecordingAppender;
property StandardErrorAppender
StandardErrorAppender: StandardErrorAppender;
property StandardOutputAppender
StandardOutputAppender: StandardOutputAppender;
property SyncfileAppender
SyncfileAppender: SyncfileAppender;
property TCPAppender
TCPAppender: TCPAppender;
interface BasicLayout
interface BasicLayout {}
property type
type: 'basic';
interface CallStack
interface CallStack {}
A parsed CallStack from an
Error.stack
trace
property callStack
callStack: string;
The stack string after the skipped lines
property columnNumber
columnNumber: number;
property fileName
fileName: string;
property functionName
functionName: string;
property lineNumber
lineNumber: number;
interface CategoryFilterAppender
interface CategoryFilterAppender {}
Category Filter
See Also
https://log4js-node.github.io/log4js-node/categoryFilter.html
interface ColoredLayout
interface ColoredLayout {}
property type
type: 'colored' | 'coloured';
interface Configuration
interface Configuration {}
property appenders
appenders: { [name: string]: Appender };
property categories
categories: { [name: string]: { appenders: string[]; level: string; enableCallStack?: boolean; };};
property disableClustering
disableClustering?: boolean;
property levels
levels?: | Levels | { [name: string]: { value: number; colour: string; }; };
property pm2
pm2?: boolean;
property pm2InstanceVar
pm2InstanceVar?: string;
interface ConsoleAppender
interface ConsoleAppender {}
Console Appender
See Also
https://log4js-node.github.io/log4js-node/console.html
interface CustomAppender
interface CustomAppender {}
property type
type: string | AppenderModule;
index signature
[key: string]: any;
interface CustomLayout
interface CustomLayout {}
property type
type: string;
index signature
[key: string]: any;
interface DateFileAppender
interface DateFileAppender {}
property alwaysIncludePattern
alwaysIncludePattern?: boolean;
property compress
compress?: boolean;
property encoding
encoding?: string;
property filename
filename: string;
property fileNameSep
fileNameSep?: string;
property flags
flags?: string;
property keepFileExt
keepFileExt?: boolean;
property layout
layout?: Layout;
property mode
mode?: number;
property numBackups
numBackups?: number;
property pattern
pattern?: string;
The following strings are recognised in the pattern: - yyyy : the full year, use yy for just the last two digits - MM : the month - dd : the day of the month - hh : the hour of the day (24-hour clock) - mm : the minute of the hour - ss : seconds - SSS : milliseconds (although I'm not sure you'd want to roll your logs every millisecond) - O : timezone (capital letter o)
property type
type: 'dateFile';
interface DummyLayout
interface DummyLayout {}
property type
type: 'dummy';
interface FileAppender
interface FileAppender {}
property backups
backups?: number;
property compress
compress?: boolean;
property encoding
encoding?: string;
property filename
filename: string;
property fileNameSep
fileNameSep?: string;
property flags
flags?: string;
property keepFileExt
keepFileExt?: boolean;
property layout
layout?: Layout;
property maxLogSize
maxLogSize?: number | string;
property mode
mode?: number;
property type
type: 'file';
interface LayoutsParam
interface LayoutsParam {}
property addLayout
addLayout: (name: string, serializerGenerator: LayoutFunction) => void;
property basicLayout
basicLayout: LayoutFunction;
property coloredLayout
coloredLayout: LayoutFunction;
property colouredLayout
colouredLayout: LayoutFunction;
property dummyLayout
dummyLayout: LayoutFunction;
property layout
layout: (name: string, config: PatternToken) => LayoutFunction;
property messagePassThroughLayout
messagePassThroughLayout: LayoutFunction;
property patternLayout
patternLayout: LayoutFunction;
interface Level
interface Level {}
property colour
colour: string;
property level
level: number;
property levelStr
levelStr: string;
method isEqualTo
isEqualTo: { (other: string): boolean; (otherLevel: Level): boolean };
method isGreaterThanOrEqualTo
isGreaterThanOrEqualTo: { (other: string): boolean; (otherLevel: Level): boolean;};
method isLessThanOrEqualTo
isLessThanOrEqualTo: { (other: string): boolean; (otherLevel: Level): boolean };
interface Levels
interface Levels {}
property ALL
ALL: Level;
property DEBUG
DEBUG: Level;
property ERROR
ERROR: Level;
property FATAL
FATAL: Level;
property INFO
INFO: Level;
property levels
levels: Level[];
property MARK
MARK: Level;
property OFF
OFF: Level;
property TRACE
TRACE: Level;
property WARN
WARN: Level;
method addLevels
addLevels: (customLevels: object) => void;
method getLevel
getLevel: (level: Level | string, defaultLevel?: Level) => Level;
interface Log4js
interface Log4js {}
property levels
levels: Levels;
method addLayout
addLayout: ( name: string, config: (a: any) => (logEvent: LoggingEvent) => string) => void;
method configure
configure: { (filename: string): Log4js; (config: Configuration): Log4js };
method connectLogger
connectLogger: ( logger: Logger, options: { format?: Format; level?: string; nolog?: any }) => any;
method getLogger
getLogger: (category?: string) => Logger;
method isConfigured
isConfigured: () => boolean;
method shutdown
shutdown: (cb?: (error?: Error) => void) => void;
interface Logger
interface Logger {}
property callStackLinesToSkip
callStackLinesToSkip: number;
Adjust the value of linesToSkip when the parseFunction is called.
Cannot be less than 0.
property category
readonly category: string;
property level
level: Level | string;
method addContext
addContext: (key: string, value: any) => void;
method clearContext
clearContext: () => void;
method debug
debug: (message: any, ...args: any[]) => void;
method error
error: (message: any, ...args: any[]) => void;
method fatal
fatal: (message: any, ...args: any[]) => void;
method info
info: (message: any, ...args: any[]) => void;
method isDebugEnabled
isDebugEnabled: () => boolean;
method isErrorEnabled
isErrorEnabled: () => boolean;
method isFatalEnabled
isFatalEnabled: () => boolean;
method isInfoEnabled
isInfoEnabled: () => boolean;
method isLevelEnabled
isLevelEnabled: (level?: string) => boolean;
method isTraceEnabled
isTraceEnabled: () => boolean;
method isWarnEnabled
isWarnEnabled: () => boolean;
method log
log: (level: Level | string, ...args: any[]) => void;
method mark
mark: (message: any, ...args: any[]) => void;
method removeContext
removeContext: (key: string) => void;
method setParseCallStackFunction
setParseCallStackFunction: ( parseFunction: (error: Error, linesToSkip: number) => CallStack | undefined) => void;
Replace the basic parse function with a new custom one - Note that linesToSkip will be based on the origin of the Error object in addition to the callStackLinesToSkip (at least 1)
Parameter parseFunction
the new parseFunction. Use
undefined
to reset to the base implementation
method trace
trace: (message: any, ...args: any[]) => void;
method warn
warn: (message: any, ...args: any[]) => void;
construct signature
new (name: string): Logger;
interface LoggingEvent
interface LoggingEvent extends Partial<CallStack> {}
property categoryName
categoryName: string;
property cluster
cluster?: { workerId: number; worker: number;};
property context
context: any;
property data
data: any[];
property error
error?: Error;
The first Error object in the data if there is one
property level
level: Level;
property pid
pid: number;
property startTime
startTime: Date;
method serialise
serialise: () => string;
interface LogLevelFilterAppender
interface LogLevelFilterAppender {}
interface MessagePassThroughLayout
interface MessagePassThroughLayout {}
property type
type: 'messagePassThrough';
interface MultiFileAppender
interface MultiFileAppender {}
interface MultiprocessAppender
interface MultiprocessAppender {}
property appender
appender?: string;
property loggerHost
loggerHost?: string;
property loggerPort
loggerPort?: number;
property mode
mode: 'master' | 'worker';
property type
type: 'multiprocess';
interface NoLogFilterAppender
interface NoLogFilterAppender {}
No Log Filter
See Also
https://log4js-node.github.io/log4js-node/noLogFilter.html
interface PatternLayout
interface PatternLayout {}
interface PatternToken
interface PatternToken {}
interface Recording
interface Recording {}
interface RecordingAppender
interface RecordingAppender {}
property type
type: 'recording';
interface StandardErrorAppender
interface StandardErrorAppender {}
interface StandardOutputAppender
interface StandardOutputAppender {}
interface SyncfileAppender
interface SyncfileAppender {}
Type Aliases
type Appender
type Appender = Appenders[keyof Appenders];
type AppenderFunction
type AppenderFunction = (loggingEvent: LoggingEvent) => void;
type Config
type Config = any;
type Format
type Format = | string | ((req: any, res: any, formatter: (str: string) => string) => string);
type Layout
type Layout = | BasicLayout | ColoredLayout | MessagePassThroughLayout | DummyLayout | PatternLayout | CustomLayout;
type LayoutFunction
type LayoutFunction = (loggingEvent: LoggingEvent) => string;
type Token
type Token = ((logEvent: LoggingEvent) => string) | string;
Package Files (1)
Dependencies (5)
Dev Dependencies (19)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/log4js
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/log4js)
- HTML<a href="https://www.jsdocs.io/package/log4js"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2063 ms. - Missing or incorrect documentation? Open an issue for this package.