Jason Brown edited this page Dec 15, 2016 · 9 revisions

The core appenders are:

Appenders can be loaded from anywhere on the require path (node_modules, NODE_PATH) in two ways. Firstly by explicitly loading them in the code log4js.loadAppender("some/external/module") and then referring to them like this: log4js.addAppender(log4js.appenders["some/external/module"](args)). Secondly, by using the type field in the appender config object / json file:

{ "appenders": [
    { "type": "some/external/module", "options": "blah" }
] }

Custom Appenders

Appender modules need to export two functions: configure and appender. Configure is called during a log4js.configure(...) call, and is passed the row in the appenders list that applies to that type of appender, along with the global log4js options. It should return an appender instance. The appender function is used when setting up appenders programmatically. See the core appenders in the lib/appenders directory for examples.