• Hi, Pleskians! We are running a UX testing of our upcoming product intended for server management and monitoring.
    We would like to invite you to have a call with us and have some fun checking our prototype. The agenda is pretty simple - we bring new design and some scenarios that you need to walk through and succeed. We will be watching and taking insights for further development of the design.
    If you would like to participate, please use this link to book a meeting. We will sent the link to the clickable prototype at the meeting.
  • (Plesk for Windows):
    MySQL Connector/ODBC 3.51, 5.1, and 5.3 are no longer shipped with Plesk because they have reached end of life. MariaDB Connector/ODBC 64-bit 3.2.4 is now used instead.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

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