appsignal

Transport Your Logs to AppSignal with Winston

Connor James

Connor James on

Transport Your Logs to AppSignal with Winston

AppSignal Logging gives you 360-degree insights into your application's performance. To help give you those insights, we wanted to ensure our logging solution allowed you to send AppSignal your logs your way.

You can now use Winston transport to send your Node.js application's logs directly to AppSignal and take advantage of having access to all of your application's performance logs and metrics in one place.

Turbocharge Your Troubleshooting With AppSignal + Winston

Our Winston transport integrates seamlessly into your Node.js application, allowing you to continue utilizing Winston while simultaneously sending essential logging data to AppSignal for future debugging sessions. With AppSignal and Winston, you can consolidate your logging and monitoring tooling in one powerful platform to gain a comprehensive view of your application data, eliminate blind spots, and enhance the effectiveness of your debugging efforts.

We know the importance of having quick access to crucial data when problem-solving. With tools like Time Detective, AppSignal allows you to jump from reviewing an incident to reading a log line in just a few clicks of the mouse. You can quickly delve deeper into your code and gain the meaningful insights necessary to find the root cause of a problem without even having to query your logs manually.

Once AppSignal has ingested your application's Winston logs, you'll be able to:

  • Easily find the logs you need with our intuitive search and filtering functionality.
Screenshot of filtering
  • Visualize the severity of your application's logs with interactive charts that help you dive deeper into your application logs with a single click.
Screenshot of filtering
  • Create custom views of your logs using filters and organize them in a way that makes sense for your application.

Thanks to AppSignal's powerful tooling, you won't be blocked by sketchy SSH connections or complex query interfaces. Instead, you'll be able to level up your problem-solving prowess by having instant access to the metrics that matter when they matter.

Transporting Your Winston Logs to AppSignal

With the AppSignal transport, you can send Winston logs straight to AppSignal.

First, import our transport from the AppSignal integration and add it to your Winston logger's transports list. You can add multiple transports with different logging levels, enabling you to send your logs to different destinations with varying levels of detail. You may wish to use only the Console transport for debugging messages, but both the console and AppSignal transport for info messages.

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

Tags can provide you with greater context when debugging logs in the future - for example, when you want to filter logs based on a specific attribute value, such as a UUID, or to create a custom log view based on attributes you want frequent logging insights into.

In the example below, an API endpoint handles customers' orders. To help us keep this endpoint healthy, we're using Winston to log important information. So it's easier to filter logs by user, a child logger has been created, with the userID set as the sessionID; this ensures we can view all logs written by the child logger without having to supply the user or session ID as metadata continuously.

We provide additional contextual information as metadata when writing new log lines, such as the roast, drinkID, and baristaID. These tags give us greater insights into the logic our application is handling. We can use these tags to search and filter logs based on AppSignal's logging tool, giving us quick access to the contextual information we need.

javascript
const logger = winston.createLogger({...}); const sessionLogger = logger.child({ sessionID: user.id, }); app.get('/order-coffee', (req, res) => { sessionLogger.debug("User order request recieved"); const drinkID = req.params.drinkId const roast = req.params.roast const coffeeBeans = pickCoffeeBeans(roast) sessionLogger.info("Order beans selected", { roast: roast, beansID: coffeeBeans.id, drinkID: drinkID}); const barista = designateBarista(coffeeBeans, drinkID) sessionLogger.info("Order sent to barista", { baristaID: barista.id }); }) }

If something goes wrong, we can use our logs to gain additional context and help us understand why. For example, with the additional context the tags provide, we can deduce if our application has failed to process every order correctly, or if it is just users who want a frappuccino who are being left thirsty.

Screenshot of filtering

Debugging with a buddy? You can copy log messages as JSON or generate a URL to link fellow debuggers directly to the log message you're investigating.

Before importing the AppSignal transport to Winston, ensure your AppSignal for Node.js package is version 3.0.3 or higher. As ever, or documentation offers detailed instructions on how to set up your Node.js application to send its Winston logs to AppSignal.

More Ways To Log

AppSignal Logging also supports the following popular platforms, so you can set up log sources that match your stack and get valuable insights into various layers of your application's processes:

Supported Log Sources
AWS Kinesis / CloudWatch
Clever Cloud
Gigalixir Log Drain
Heroku Log Drain
HTTP (API)
Netlify
Scalingo
Syslog
Vercel

You can also send logs to AppSignal in other formats such as JSON or LogFmt. Find more information on supported formats and platforms in our Logging documentation.

Log On, Log Off

With AppSignal's Winston transport, you can be on your way to 360-degree insights into your application's performance within minutes and potentially shave hours off future debugging sessions.

If you're ready to get started with AppSignal Logging, our documentation has all the information you need to send your logs to AppSignal. If you get stuck, you can always contact us for dev-to-dev support.

New to AppSignal? Don't forget to claim your free stroopwafels. We love sending them to trial users upon request!

Connor James

Connor James

Official technical writer at AppSignal. Podcast addict who loves cannoli so much that he's considering changing his name to Connoli. He thinks there's a `u` in color. You might find him on the mic, on the stage, or lying on the sofa when he's off Documentation Duty.

All articles by Connor James

Become our next author!

Find out more

AppSignal monitors your apps

AppSignal provides insights for Ruby, Rails, Elixir, Phoenix, Node.js, Express and many other frameworks and libraries. We are located in beautiful Amsterdam. We love stroopwafels. If you do too, let us know. We might send you some!

Discover AppSignal
AppSignal monitors your apps