• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Question Error logs Phusion Passenger nginx Nodejs

LukasBe

New Pleskian
Hello Plesk-Community,

I have a NodeJs-App running with Phusion Passenger and nginx on Plesk.
The instructions for the passenger configuration to setup a path for the log files isn't working in my case.

Is there anybody who knows how to setup up error logs?

I have apended my config file.

Thank you in advance.

Kind regards
Lukas


passenger_root /usr/share/passenger/phusion_passenger/locations.ini;

# Avoid downloading of sources or binary for ruby passenger_native_support.so
# after each nginx restart by default because of development packages
# or libruby.so.X.Y may be missed anyway.
# Ruby passenger_native_support.so is packaged for system ruby only.
passenger_env_var PASSENGER_COMPILE_NATIVE_SUPPORT_BINARY 0;
passenger_env_var PASSENGER_DOWNLOAD_NATIVE_SUPPORT_BINARY 0;
passenger_log_file /var/log/passenger_log/passenger.log
 
My solution

// initErrorLogs.js

import path from 'path';
import fs from 'fs';
import util from 'util';

var log_file = fs.createWriteStream(path.resolve('node.log'), {flags : 'w'});
var log_stdout = process.stdout;

const formatDate = (date = new Date()) => {
var year = date.getFullYear(),
month = date.getMonth() + 1, // months are zero indexed
day = date.getDate(),
hour = date.getHours(),
minute = date.getMinutes(),
second = date.getSeconds(),
hourFormatted = hour % 12 || 12, // hour returned in 24 hour format
minuteFormatted = minute < 10 ? "0" + minute : minute;

return day + "." + month + "." + year + " - " + hourFormatted + ":" + minuteFormatted;
}

var _log = console.log;

console.log = function(...args){
var output = args.join(' ');

if(!output.includes('SyncedCron'))
log_file.write('['+ formatDate() +' | console.log] '+ util.format(output) + '\r\n');

_log.apply(console,args);
};

process.on('uncaughtException', (err) => {
log_file.write('['+ formatDate() +' | uncaughtException] '+ util.format(err) + '\r\n');
log_stdout.write(util.format(err) + '\r\n');
});

process.on('warning', (warning) => {
log_file.write('['+ formatDate() +' | warning] '+ util.format(warning) + '\r\n');
});

process.on('unhandledRejection', (reason, promise) => {
log_file.write('['+ formatDate() +' | unhandledRejection] '+ util.format({promise, reason}) + '\r\n');
});

process.on('message', (message, sendHandle) => {
log_file.write('['+ formatDate() +' | message] '+ util.format({message, sendHandle}) + '\r\n');
});
 
Hi LukasBe,

are you still going with your own log-solution?

The instructions for the passenger configuration to setup a path for the log files isn't working in my case either (PassengerLogFile).

Anyone has a different solution?
 
Back
Top