• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • 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.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

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