Knowledgebase

How to separate the NodeJS / Python / Ruby Selectors Passenger logs from the Apache error.log?

To separate the logs for NodeJS, Python, and Ruby applications when using Passenger with Apache, you'll need to configure Passenger to use individual log files for each application. This can be achieved by setting up Virtual Hosts for each application and specifying custom log file paths.

Here's a step-by-step guide:

  1. Create Separate Virtual Hosts:

    • Open your Apache configuration file (usually located at /etc/httpd/conf/httpd.conf on Linux or httpd.conf in Windows).
    • Create separate VirtualHost blocks for each application, like so:
    apache

 

  • <VirtualHost *:80> ServerName nodejs.example.com DocumentRoot /path/to/your/nodejs/app PassengerAppType node PassengerStartupFile app.js PassengerLogFile /var/log/nodejs/passenger.log </VirtualHost> <VirtualHost *:80> ServerName python.example.com DocumentRoot /path/to/your/python/app PassengerAppType wsgi PassengerStartupFile your_wsgi_file.py PassengerLogFile /var/log/python/passenger.log </VirtualHost> <VirtualHost *:80> ServerName ruby.example.com DocumentRoot /path/to/your/ruby/app PassengerAppType rack PassengerStartupFile config.ru PassengerLogFile /var/log/ruby/passenger.log </VirtualHost>

    Replace /path/to/your/nodejs/app, /path/to/your/python/app, and /path/to/your/ruby/app with the actual paths to your applications.

  • Create Log Directories:

    • Create directories for the logs:
    bash
  • sudo mkdir /var/log/nodejs sudo mkdir /var/log/python sudo mkdir /var/log/ruby

    Make sure the directories have the necessary permissions for the Apache process to write to them.

  • Restart Apache:

    • After making these changes, restart Apache for the changes to take effect:
    bash

 

sudo systemctl restart apache2 # For systemd-based systems

or

bash
  1. sudo service httpd restart # For non-systemd systems

Now, Passenger will create separate log files for each application. The log files will be located at:

  • /var/log/nodejs/passenger.log
  • /var/log/python/passenger.log
  • /var/log/ruby/passenger.log

These logs will contain output specific to the respective application type (Node.js, Python, or Ruby). The Apache error.log file will continue to contain general Apache errors and logs.

 
  • 0 Users Found This Useful
Was this answer helpful?