Logs: Multiple Servers sharing 1 vhost conf file

Alles, was den Apache betrifft, kann hier besprochen werden.

Logs: Multiple Servers sharing 1 vhost conf file

Postby chomps » 13. December 2016 13:36

Hi,

I have a situation where I have 3 Apache 2.4.7 Servers and all 3 have mount points set up to one location on another server. They therefore all share the same Apache 'vhost.conf' file.
I would like to have the logs from each host in separate files. Does anyone know how to do this?

Currently:
ErrorLog /home/app/deploy/logs/error.log
CustomLog /home/app/deploy/logs/custom.log combined

I would like it to write something like:
ErrorLog /home/app/deploy/logs/{$hostname}.error.log
CustomLog /home/app/deploy/logs/{$hostname}custom.log combined

Your help is much appreciated.
chomps
 
Posts: 6
Joined: 13. December 2016 13:27
XAMPP version: 2.4.7
Operating System: Linux

Re: Logs: Multiple Servers sharing 1 vhost conf file

Postby Nobbie » 14. December 2016 21:52

chomps wrote:I have a situation where I have 3 Apache 2.4.7 Servers and all 3 have mount points set up to one location on another server.


This is very hard to understand, can you explain more precisely what is meant by that? Apache does not "mount" locations, that is where my understanding begins zu struggle. What is meant by "mount point" for Apache?

P.S.: What i also dont understand - if you have 3 different Apaches, which serves the same VirtualHost (for example www.aaa.bb) - which of the three Apache serves www.aaa.bb and how does a a browser know, which Apache is responsible for www.aaa.bb?
Nobbie
 
Posts: 13171
Joined: 09. March 2008 13:04

Re: Logs: Multiple Servers sharing 1 vhost conf file

Postby chomps » 14. February 2017 13:35

Sorry a reply took too long for me to come back here. I see this now only, so my solution was quite simple. You don't need to touch the vhost file that contains your block directives.
I think you miss understood the mount points. mount points have nothing to do with apache. what I said was all 3 servers have a mount point on another server. (ie normal linux mount point). If you not sure what a mount point is then you need to look that up and it is beyond the scope of this question.
All I wanted to do was move the default log file location from the standard (/var/log/apache2/) to a mount point (ie: /mnt/apache2/logs/server1)
So the solution to this was to have the following in the vhost block:

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/custom.log combined

And then change your envars file (environment variables) on each server:
change #export APACHE_LOG_DIR=/var/log/apache2$SUFFIX
to
export APACHE_LOG_DIR=/mnt/apache2/logs/server1

In this way they all write to the same location and the endpoint has each servers logs in its own directory.

Hope this helps
chomps
 
Posts: 6
Joined: 13. December 2016 13:27
XAMPP version: 2.4.7
Operating System: Linux

Re: Logs: Multiple Servers sharing 1 vhost conf file

Postby Nobbie » 14. February 2017 14:07

chomps wrote:If you not sure what a mount point is then you need to look that up and it is beyond the scope of this question.


I am working with UNIX since 1986, i have heard about a mount.... but i had never seen it in a Apache configuration.

chomps wrote:In this way they all write to the same location and the endpoint has each servers logs in its own directory.


I dont find this solution very logical, as you need different environments for the different Apache installations. I would simply hard link the configuration files to each other and then evaluate the file name ($0) instead of an environment variable.
Nobbie
 
Posts: 13171
Joined: 09. March 2008 13:04


Return to Apache

Who is online

Users browsing this forum: No registered users and 30 guests