Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

logFaces Appender (HTTP) for log4js-node

The logFaces appenders send JSON formatted log events to logFaces receivers. This appender uses HTTP to send the events (there is another logFaces appender that uses UDP).

npm install log4js @log4js-node/logfaces-http


  • type - @log4js-node/logfaces-http
  • url - string - logFaces receiver servlet URL
  • application - string (optional, defaults to empty string) - used to identify your application's logs
  • timeout - integer (optional, defaults to 5000ms) - the timeout for the HTTP request.
  • configContext - function (optional) returning a global context object accessible to all appenders. Properties from configContext added as p_ values in the logFaces event.
  • hostname - string (optional) - used to add the hostname h property to the logFaces event.
  • agent - http.Agent | https.Agent (optional) - used to configure the requests being sent out if needed.
  • eventLayout - (LoggingEvent, LogFacesEvent) => LogFacesEvent (optional) - allows more control and ability to modify and set the properties of the LogFacesEvent that will get sent to the server. Note: returning null or undefined will cause the event to be ignored and not logged. If LogFacesEvent.m is nullish, the default format for the message will be applied.

This appender will also pick up Logger context values from the events, and add them as p_ values in the logFaces event. See the example below for more details. Note that Logger context may override the same properties defined in configContext.

Example (default config)

// global context variables can be specified like this
// these variables will propagate to logFaces server with all requests
const MDC = {
  sessionID: 111,

// log4js framework configuration
  appenders: {
    logfaces: {
      type: "@log4js-node/logfaces-http",
      url: "http://lfs-server/logs",
      application: "TesterApp",
      configContext: () => MDC,
  categories: {
    default: { appenders: ["logfaces"], level: "info", enableCallStack: true },

// instances of the logger is obtained from framework like this
const logger = log4js.getLogger();

// local context variables can propagate to logFaces along with global context
logger.addContext("requestId", "123");"some interesting log message");

// global context variables can be modified anywhere in the app
MDC.sessionID = 222;
logger.error("something has gone wrong", new Error("exception message"));

This example will result in two log events being sent to lfs-server. Both events will have a requestId property with a value of 123. First event will have sessionID of 111 and second sessionID of 222. Also since enableCallStack is set, both events will include location details such as file name, function name and line number. Second event will have a stack trace of a trown error.