Logging From Node.jsBETA

AppSignal Logging is currently only available to Beta Testers. If you think your application is a good candidate, send us an email!

Configure Package

This feature is designed to work from AppSignal for Node.js integration v3 and greater.

To use logging with your AppSignal integration for Node.js, you first need to install version 3.0 of the package or higher.

Configure Logging

Log data must not contain personal data, such as names, email addresses, etc. It is your responsibility to ensure this data is filtered out before being sent to AppSignal, and when identifying a person is necessary that your application uses alternative forms of identification, such as a user ID, hash, or pseudonym.

Stand-alone usage

To use the logger, you need to import AppSignal and set up the logger using the .logger() function.

The .logger() function accepts two arguments: group and optionally severityThreshold. If severityThreshold is not provided, it will default to info.

const { Appsignal } = require("@appsignal/nodejs");
const logger = Appsignal.logger("app");

There are six severity levels available trace, debug, info, log, warn, and error each of them with its own function with the same name. These functions accept two arguments message and attributes. Attributes is used for metadata and is optional.

logger.info("Log message line");
logger.debug("User logged in", { user_id: 123 });

Note that if the message's severity is below the severity threshold set up when initializing the logger, it will not be sent to AppSignal.

You can query and filter on message contents and attribute values from within the Log Management tool.

Usage with Winston

Winston is only available in AppSignal for Node.js version 3.0.3 onwards

If you use Winston to log messages throughout your application, you can use our Winston transport to send those logs to AppSignal. After importing the transport from the AppSignal integration, add it to the list of transports in your Winston logger:

const winston = require("winston");
const { WinstonTransport } = require("@appsignal/nodejs");
const logger = winston.createLogger({
  transports: [new WinstonTransport({ group: "app" })],

Child Logger

You can use a child logger to add additional tags to log messages. You define tags when creating the child logger constant or pass tags as metadata when writing a log message. Say we want greater context in our logs of the actions of a particular user within a specific session. In the below example, a child logger is used to add sessionID with the additional drinkID, and paymentID tags are provided as metadata when creating a log message.

const logger = winston.createLogger({...});
const sessionLogger = logger.child({
  sessionID: user.id,
sessionLogger.debug("User logged in");
sessionLogger.info("User ordered coffee", { drinkID: 30, paymentID: 20082 });
sessionLogger.debug("User logged out");

Need Help?

After configuring your Node.js application to send logs, logs should appear in AppSignal. If you are unsure about this step or AppSignal is not receiving any logs, you can always reach out for assistance. We'll help get you back on track!

Need more help?

Contact us and speak directly with the engineers working on AppSignal. They will help you get set up, tweak your code and make sure you get the most out of using AppSignal.

Contact us

Start a trial - 30 days free

AppSignal is a great way to monitor your Ruby, Elixir & Node.js applications. Works great with Rails, Phoenix, Express and other frameworks, with support for background jobs too. Let's improve your apps together.

Start a trial