Unraveling the process: Navigating into the Node.js application log launched with pm2

During the development of my Node.js application, I utilized Socket.IO, Express, MySql, and https. Initially, everything was functioning perfectly until I decided to "deamonize" it using pm2. Surprisingly, after this implementation, my socket connection appears to be unresponsive, and I am now eager to debug it. Regrettably, I am unable to locate where the console.log() function is currently directing its output.

In case you are curious, all my pm2 processes are running smoothly and I can successfully refresh my client-side pages. However, there should be a server function that triggers an event on the client side whenever something occurs in the database, but unfortunately, this functionality is absent.

Can you please assist me in finding out where the output from console.log() is being directed?

Answer №2

there is an issue where your server keeps running and you want to access the logs.

Use pm2 log command and you will see all logs except console.log()

However, a simple solution exists:

Try using pm2 logs instead of pm2 log

Take note of the "s" in logs. This should resolve your problem.

Answer №3

According to the PM2 documentation:

PM2 provides an easy way to manage your application logs. You can view the real-time logs from all your applications, clear them, and reload them. There are various ways to customize how PM2 handles your logs (such as separating them into different files, merging them, adding timestamps) without any changes to your code.

http://pm2.keymetrics.io/docs/usage/log-management/

There is also another question on Stack Overflow related to this topic:

Make pm2 log to console

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The element "Footer" cannot be found in the file path "./components/footer/Footer"

After attempting to run the npm start command, I encountered the following error. In my code, I am trying to import the file /components/footer/Footer.js into the file /src/index.js //ERROR: Failed to compile. In Register.js located in ./src/components/r ...

Unable to integrate bower with gulp for automation

I am trying to get gulp to run the installation of all files listed in my bower.json. However, despite writing the code below, it is not working and I'm not seeing any errors. What could be causing this issue? var gulp = require("gulp"); var bower = ...

Installation with "npm install" encounters issues with git package dependencies on macOS Catalina

While attempting to run "npm install" on a Node.js project with a Git dependency, it encounters failure specifically on macOS Catalina. npm ERR! code EPERM npm ERR! syscall spawn npm ERR! errno EPERM npm ERR! Error: spawn EPERM npm ERR! at ChildProc ...

Is it possible to execute asynchronous queries within a map function in Mongoose?

Currently, I am struggling to create queries using a .map function, pushing the results to an array and then returning it. The issue is that the array always ends up empty due to the asynchronous nature of the operation. Although I attempted using async/ ...

Passport causing Node.JS application to crash

After developing my app to work locally, I made all necessary adjustments for Heroku. Procfile web: node app.js package.json { "name": "HipsterMatch", "version": "0.0.1", "private": true, "scripts": { "start": "nodemon app.js" }, "depen ...

The most common method for incorporating subdomains (such as the jp in jp.sweet-website.org) into nodejs applications

The current versions are Express 4.10.2 and Node 6.5.0 How can I create a subdomain for my website? I am looking to include a Japanese version of my site that will be accessible through http://jp.site-in-question.run in addition to the default English ...

filtering the properties of mongoose documents

I have created a schema as shown below: var UserSchema = new Schema({ firstName: { type: String, required: true }, lastName: { type: String, required: true }, email: { type: String, required: true }, location: { type: String, required: true }, p ...

PassportJS is providing the `req.user` functionality to transmit all user information

Currently, I am utilizing PassportJS local strategy in order to authenticate users and it seems to be functioning properly. However, whenever I attempt to console.log(req.user) on any authenticated page, I can see all the database entry details of the user ...

Why is the home page on my jade website showing a blank screen?

Currently, I am following a tutorial on Express, Mongo, and Jade. While I have successfully retrieved data from MongoDB, Jade is not rendering my page correctly. Click here for the tutorial. Here are the snippets of code I am using: app.js: app.get(&apo ...

The designated redirection path, as indicated in the 'next.config.js' file for a particular project, has now been applied to all projects

Something strange is happening... I set a redirect path for the root index page in one of my projects and it worked perfectly, but now all of my other projects are also being redirected to that same path when I try to visit localhost:3000. It's alway ...

Guide on creating middleware in Nodejs Express to manage every response

When working with node JS Express, we have the ability to create middlewares that can intercept requests and perform specific actions. There are two main ways we can handle requests within a middleware: We can pass on the request to the next middleware i ...

Is there a way for me to divide the data in a JSON file and display user tags in place of their IDs?

Looking to create a list admins command for a bot, I'm facing challenges in converting user ids to tags within the command. Take a look at what I have accomplished so far: const { MessageEmbed } = require('discord.js'); const { readFileSync, ...

Tips for verifying user authentication with OAuth2 in a React and Express Node app

Despite looking at various resources on this subject, I'm still struggling to find a solution to my specific issue. I've been utilizing the Strava API, which operates on OAuth 2.0. The process involves: Clicking the connect button Redirecting t ...

What is the best way to combine arrays?

Here is the array retrieved from the database: [ { "_id": "58144e6c0c8d7534f4307269", "doctor_id": "5813221ace684e2b3f5f0a6d", "prescription": [ { "_id": "58144e6c0c8d7534f430726a", "medicine_id": "1001124 ...

AngularJS: Where server-side templating meets modern web development

I am a beginner in the MEAN stack and recently developed an application using node.js, express, and mongodb. I would like to pass the username to the dashboard once the user logs in. How can I achieve this using AngularJS without relying on the ejs templat ...

npm fails with the error message 'ERR! callback() was not invoked'

While attempting to set up vue-cli on my system, I encountered an issue with the installation process. npm install -g @vue/cli The error message I received was: Unhandled rejection Error: EACCES: permission denied, mkdir '/home/moeketsi/.npm/_cac ...

Module 'bcryptjs' could not be located

Recently, I added the @types/bcryptjs package to my Node.js project. Initially, there were no issues with importing it. However, when I attempted to use it in my code by including the line: console.log(bcrypt.hashSync(req.body.password)) I encountered an ...

Integration of GoogleMaps API v3, creating markers using Node.JS and Javascript, utilizing require() function for module exports

I am currently working on a node.js application that displays markers on Google Maps based on locations stored in the database. These locations are then converted and saved to a .txt file. Everything works smoothly up to this point. When I use console.log( ...

Exploring the possibilities of TeamCity integration with NodeJS for streamlined API testing

I'm currently in the process of setting up a CI/CD pipeline that involves using TeamCity as the build server. The pipeline has 3 build steps that I have configured: Running npm install, Executing node server.js, Running node run_tests.js The i ...

Leveraging async-await for carrying out a task following the deletion of a collection from a mongodb database

Trying to implement async await for executing an http request prior to running other code. Specifically, wanting to delete a collection in the mongodb database before proceeding with additional tasks. This is what has been attempted: app.component.ts: ...