Winston is a pretty good logging library. You can write logs out to a file using it.

Code would look something like:

Copyvar winston = require('winston');

var logger = new (winston.Logger)({
  transports: [
    new (winston.transports.Console)({ json: false, timestamp: true }),
    new winston.transports.File({ filename: __dirname + '/debug.log', json: false })
  ],
  exceptionHandlers: [
    new (winston.transports.Console)({ json: false, timestamp: true }),
    new winston.transports.File({ filename: __dirname + '/exceptions.log', json: false })
  ],
  exitOnError: false
});

module.exports = logger;

You can then use this like:

Copyvar logger = require('./log');

logger.info('log to file');
Answer from Charlie Key on Stack Overflow
🌐
Facebook
facebook.com › JSLOGGINGPARTSANDSUPPLIES
JS Logging Parts and Supplies, llc | Saint Johnsville NY | Facebook
JS Logging Parts and Supplies, llc, Saint Johnsville. 5,315 likes · 3 talking about this · 8 were here. Provide Logging Parts and Supplies to individuals in the forestry industry.
🌐
In Praise Of Logging
engineering.deptagency.com › in-praise-of-logging-a-node-js-javascript-logging-guide
In Praise Of Logging (A Node.js/Javascript Logging Guide)
September 26, 2023 - In this post, I'm going to outline some good practices I've learned along the way and (hopefully) convince you why you should consider using a logging framework immediately instead of console.log statements.
People also ask

Which JavaScript logging library works in the browser and Node.js?
LogTape and Sentry's logger are the only options in this comparison that run natively across all runtimes; Node, Deno, Bun, browsers, and edge (Cloudflare Workers, Vercel Edge Functions). Pino and Winston are Node.js only (Pino can run in the browser via polyfill, but loses performance benefits).
🌐
blog.sentry.io
blog.sentry.io › javascript-logging-library-definitive-guide
Choosing a JavaScript Logging Library: The 2026 Definitive Guide ...
What is the fastest JavaScript logging library?
LogTape reports ~2x faster than Pino and over 10x faster than Winston.
🌐
blog.sentry.io
blog.sentry.io › javascript-logging-library-definitive-guide
Choosing a JavaScript Logging Library: The 2026 Definitive Guide ...
What is trace-connected logging?
Trace-connected logging automatically links log entries to the distributed trace they were emitted during. This means when debugging an error in Sentry, you can see the exact log lines that occurred within the same request trace, without manually correlating IDs.
🌐
blog.sentry.io
blog.sentry.io › javascript-logging-library-definitive-guide
Choosing a JavaScript Logging Library: The 2026 Definitive Guide ...
🌐
DEV Community
dev.to › dangolant › what-js-logging-library--tool-do-you-use-5e8
What JS Logging library / tool do you use? - DEV Community
September 14, 2018 - By default, only Error and Warning message will show up in the console in browsers, meaning you can log as much as you want and only those people that are interested in it will actually see it. You can just leave your log statements in your production code. In Node JS we use INFO as the default level because there the 'users' are mostly developers / server admins etc who are more interested in our logging.
🌐
W3Schools
w3schools.com › nodejs › nodejs_logging.asp
Node.js Logging
Effective logging helps you debug, monitor, and understand your Node.js applications in production.
🌐
Sentry
blog.sentry.io › javascript-logging-library-definitive-guide
Choosing a JavaScript Logging Library: The 2026 Definitive Guide | Sentry Blog
March 16, 2026 - LogTape and Sentry's logger are the only options in this comparison that run natively across all runtimes; Node, Deno, Bun, browsers, and edge (Cloudflare Workers, Vercel Edge Functions). Pino and Winston are Node.js only (Pino can run in the browser via polyfill, but loses performance benefits).
🌐
Dash0
dash0.com › home › guides › the top 7 node.js logging libraries compared
The Top 7 Node.js Logging Libraries Compared · Dash0
April 22, 2026 - Production logging demands structured data, configurable verbosity, and the ability to integrate with observability systems like OpenTelemetry and centralized log pipelines. The Node.js ecosystem offers several mature libraries that go far beyond console.log()Copy.
Find elsewhere
🌐
Stackify
stackify.com › javascript-logging-basic-tips
JavaScript Logging Basic Tips - Stackify
March 17, 2023 - Learn the essential aspects of client-side JavaScript error logging to help polish your debugging skills. Find the best tips and tools to get you started.
🌐
GitHub
github.com › winstonjs › winston
GitHub - winstonjs/winston: A logger for just about everything. · GitHub
A logger for just about everything. Contribute to winstonjs/winston development by creating an account on GitHub.
Starred by 24.5K users
Forked by 1.8K users
Languages   JavaScript 99.2% | TypeScript 0.8%
🌐
LaunchDarkly
launchdarkly.com › docs › tutorials › nodejs-logging-libraries
5 Best Node.js Logging Libraries | LaunchDarkly | Documentation
Winston logs only messages in levels from info to error. To see all messages, you have to assign a level property to the config object: Currently, the code in our winston_demo.js file prints JSON logs without dates.
🌐
Loggly
loggly.com › home › javascript logging setup and troubleshooting
JavaScript Logging Setup and Troubleshooting | Loggly
June 26, 2025 - ® to parse and analyze the data. For example, Loggly offers the loggly-jslogger package to pipe log data from your JavaScript application.
🌐
GitHub
github.com › visionmedia › log.js
GitHub - tj/log.js: super light-weight nodejs logging + streaming log reader · GitHub
Lightweight logging for NodeJS.
Starred by 371 users
Forked by 82 users
Languages   HTML 72.1% | JavaScript 26.2% | Makefile 1.7%
🌐
npm
npmjs.com › package › js-logging
js-logging - npm
A powerful, feature rich and customizable logging library for node.js and any browser.. Latest version: 0.1.0, last published: 10 years ago. Start using js-logging in your project by running `npm i js-logging`. There are 1 other projects in the npm registry using js-logging.
      » npm install js-logging
    
Published   Jun 05, 2016
Version   0.1.0
🌐
Better Stack
betterstack.com › community › guides › logging › best-nodejs-logging-libraries
Logging in Node.js: A Comparison of the Top 8 Libraries | Better Stack Community
This article compares the top 8 Node.js logging libraries, discussing their features, pros and cons, and providing recommendations for which library is right for you
🌐
University of Illinois Urbana-Champaign
registrar.illinois.edu › academic-records › dars-audit
Degree Audit | Office of the Registrar | Illinois
Once logged in, if a degree audit has been run in the past, you will see the most recently run audit. If no previous degree audits have been run, you will be taken to the welcome page. From the welcome page, you can run an audit by clicking the “Request Audit” button or select “Request ...
🌐
CrowdStrike
crowdstrike.com › en-us › guides › nodejs-logging
Node.js Logging: The Basics
September 19, 2024 - When troubleshooting issues with your application, you can proactively add console logging statements to your code for certain edge cases. You can also add them retroactively to narrow down when and where issues are occurring. The following example shows calls to the different functions from the console class. ... When running your Node.js application via the terminal, both the error and log message streams are available to you, and all messages appear in the format shown below:
🌐
Amodshinde
amodshinde.com › blog › nodejs-logging
Best Practices for Logging in Node.js | Personal Blog
October 19, 2020 - One of the main goals of logging is to enable post-mortem debugging, which involves reading log entries and reconstructing the steps that led to an event in the system. Thus human-readable and easily understandable, descriptive messages will help developers and sysadmins. It’s also important to use a structured format that is easy to parse by machines. One of the best practices is to use JSON for logging as it is easily readable by humans as well as can be parsed by machines and can be easily converted to other formats.
🌐
Better Stack
betterstack.com › docs › logs › javascript › logging
JavaScript advanced usage | Better Stack Documentation
logtail.warn("Something is not quite right.", { user: { username: "John Doe", email: "john@example.com" }, additional_info: { tried_accessing: "/url/of/error" } }); ... { "dt":"2022-02-01 12:01:10.127 UTC", "context":{ "runtime":{ "column_integer":"8", "file_string":"index.js", "line_integer":"29", "type_string":"Object" }, "system":{ "main_file_string":"/mnt/d/js_logtail/index.js", "pid_integer":"4193" } }, "level_string":"warn", "message_string":"Something is not quite right.", "additional_info":{ "tried_accessing_string":"/url/of/error" }, "user":{ "email_string":"someuser@example.com", "username_string":"someuser" } }
🌐
Better Programming
betterprogramming.pub › a-complete-guide-to-node-js-logging-1ba70a4a346d
A Complete Guide to Node.js Logging | by Yasas Sandeepa | Better Programming
September 22, 2021 - A Complete Guide to Node.js Logging With the best practices for logging If I ask you a question, which JavaScript function is most useful for finding errors, your obvious answer is console.log. It is …
🌐
Medium
medium.com › @rameshkannanyt0078 › improving-logging-in-node-js-why-loggers-matter-and-top-libraries-to-consider-466c9d9d620b
Improving Logging in Node.js: Why Loggers Matter and Top Libraries to Consider | by Ramesh Kannan s | Medium
May 7, 2024 - When developing Node.js applications, logging plays a crucial role in tracking down bugs, understanding application behavior, and monitoring system performance. While the built-in console object is useful for simple output messages, it lacks ...