Talespin_Kit
Talespin_Kit

Reputation: 21877

How to change the time zone in the pm2 logs

The following is the application delcaration json file

{
  "apps" : [{
    "name"        : "test_v2",
    "script"      : "bin/www",
    "log_date_format"  : "YYYY-MM-DD HH:mm Z",
    "ignore_watch" : ["[\\/\\\\]\\./", "node_modules"],
    "watch"       : true,
    "node_args"   : "--harmony",
    "cwd"         : "/root/src/test_v2",
    "env": {
        "NODE_ENV": "production",
        "AWESOME_SERVICE_API_TOKEN": "xxx",
        "TZ": "America/Los_Angeles"
    }
  }]
}

To change the time zone, i had followed as commented at https://github.com/Unitech/pm2/issues/560

But it does not work. The behavior is the same as thought the "TZ" is not present. I tried even hard coding the time zone to numeric value like "+08:00" which does not work. How to change the time zone in the logs.

Upvotes: 5

Views: 9112

Answers (2)

billythemusical
billythemusical

Reputation: 11

From that same Github issue mentioned above, this helped me:

First update the format (make sure server timezone is what you want)

pm2 restart 0 --log-date-format "HH:mm:ss DD-MM-YYYY Z"

save all processes

pm2 save

run these

npm i -G pm2 //if not latest 
pm2 update

Upvotes: 1

soyuka
soyuka

Reputation: 9105

log_date_format in directly used with momentjs in pm2 - source.

The following options are available in moment.

I don't think that timezone has been implemented in any way but you can remove Z and use the UTC time.

If you really need a timezone implementation, fire a feature issue on pm2.

Upvotes: 3

Related Questions