GoLang application non error level logs are written to stderr
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 43.3k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
What's going wrong?
- When running a GoLang process with PM2 the standard logs are being written to the stderr stream.
How could we reproduce this issue?
- Paste the below code to a
main.gofile which logs a simple "Hello World" message.
package main
import (
"log"
)
func main() {
log.Println("Hello World!")
}
- Run
go mod init example-appandgo mod tidy - Build the exec with
go build - Run the app with PM2 (
pm2 start ./example-app --name example) - When you run
pm2 logs exampleyou will notice that the "Hello World" log is written to error file
Supporting information
--- PM2 report ----------------------------------------------------------------
Date : Thu May 11 2023 08:09:20 GMT+0000 (Coordinated Universal Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version : 5.2.2
node version : 14.21.1
node path : /usr/bin/npm
argv : /usr/bin/node,/usr/lib/node_modules/pm2/lib/Daemon.js
argv0 : node
user : ubuntu
uid : 1000
gid : 1000
uptime : 172729min
===============================================================================
--- CLI ----------------------------------------------------
local pm2 : 5.2.2
node version : 14.21.1
node path : /usr/bin/pm2
argv : /usr/bin/node,/usr/bin/pm2,report
argv0 : node
user : ubuntu
uid : 1000
gid : 1000
===============================================================================
--- System info --------------------------------------------
arch : x64
platform : linux
type : Linux
cpus : Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz
cpus nb : 2
freemem : 543625216
totalmem : 4120186880
home : /home/ubuntu
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬─────────────────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├─────┼─────────────────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 7 │ qa-alert-service │ default │ 1.0.0 │ fork │ 6258 │ 3M │ 0 │ online │ 0.4% │ 66.1mb │ ubuntu │ disabled │
│ 0 │ qa-api-encrypted │ default │ 1.361.… │ fork │ 21011 │ 20h │ 710 │ online │ 0.4% │ 213.9mb │ ubuntu │ disabled │
│ 1 │ qa-api-v2 │ default │ 0.0.1 │ fork │ 4074 │ 55D │ 10 │ online │ 0.4% │ 191.0mb │ ubuntu │ disabled │
│ 3 │ qa-data-dump-tool │ default │ 1.0.0 │ fork │ 25085 │ 39m │ 425 │ online │ 0.4% │ 90.2mb │ ubuntu │ disabled │
│ 5 │ qa-delete-matter-service │ default │ 1.0.0 │ fork │ 7449 │ 7D │ 13 │ online │ 0.4% │ 69.1mb │ ubuntu │ disabled │
│ 4 │ qa-dropbox-service │ default │ 1.0.0 │ fork │ 16989 │ 3M │ 31 │ online │ 0% │ 72.3mb │ ubuntu │ disabled │
│ 6 │ qa-gcm-bulk-upload │ default │ 1.0.0 │ fork │ 28856 │ 8D │ 2 │ online │ 0% │ 77.0mb │ ubuntu │ disabled │
│ 2 │ qa-reporting-service │ default │ 0.0.0 │ fork │ 25074 │ 39m │ 291 │ online │ 0.4% │ 81.0mb │ ubuntu │ disabled │
│ 8 │ qa-rtm-mqtt │ default │ 1.0.0 │ fork │ 6294 │ 3M │ 0 │ online │ 0.4% │ 75.8mb │ ubuntu │ disabled │
│ 10 │ qa-timesheet-service │ default │ N/A │ fork │ 14841 │ 34h │ 1522 │ online │ 0% │ 18.3mb │ ubuntu │ disabled │
│ 11 │ timesheet-service-old │ default │ N/A │ fork │ 30634 │ 41D │ 0 │ online │ 0% │ 10.0mb │ ubuntu │ disabled │
└─────┴─────────────────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
[PM2][WARN] Current process list is not synchronized with saved list. Type 'pm2 save' to synchronize.
===============================================================================
--- Daemon logs --------------------------------------------
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the main.go reproduction and run the listed go build, pm2 start, and pm2 logs commands to confirm where the output is classified. Then inspect PM2's handling of the child process streams; done means ordinary Go log output appears in the standard log rather than the error log.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, nodejs
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100