LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-29-2019, 11:03 AM   #1
witchkinkofangmar
Member
 
Registered: May 2019
Posts: 83

Rep: Reputation: Disabled
Setting up custom logging for access, error, and ssl with Apache on CentOS 7


This is my current setup that is working on Server version: Apache/2.4.6 (CentOS):
Code:
#Custom Logs
LogFormat "%v %l %u %t \"%r\" %>s %b" comonvhost
CustomLog /logs/sitename/access_log comonvhost
ErrorLog /logs/sitename/error_log
I haven't been able to find and confim if two CustomLog directives will work in a virtualhost config. Some say yes, some say no. I would like to get the ssl logs to write to a different location as well.

Code:
#Custom Logs
LogFormat "%v %l %u %t \"%r\" %>s %b" comonvhost
CustomLog /logs/sitename/access_log comonvhost
CustomLog /logs/sitename/ssl_access_log comonvhost
ErrorLog /logs/sitename/error_log
I don't get any errors when doing a apachectl configtest
 
Old 07-29-2019, 11:27 AM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,732

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
We set up a different log file for each virtual host. Works just fine. Simply set
Code:
ErrorLog logs/domainname-error_log
CustomLog logs/domainname-access_log combined
(where domainname reflects the ServerName), in each VirtualHost container,

You could also do what you propose and have a sub-directory for each domain, but I think that would be unwieldy. Naming the log files per domain works well enough.

You could even point all domains to the same log files...but that would be VERY confusing should you need to troubleshoot a specific domain, so I say don't do that!

Last edited by scasey; 07-29-2019 at 11:31 AM.
 
2 members found this post helpful.
Old 07-29-2019, 12:34 PM   #3
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,
Quote:
I haven't been able to find and confim if two CustomLog directives will work in a virtualhost config. Some say yes, some say no. I would like to get the ssl logs to write to a different location as well.
You should use one CustomLog directive for the plain http vhost and another one for the ssl vhost.
You may take a look also at the CustomLog format options for logging SSL requests.
 
1 members found this post helpful.
Old 07-29-2019, 01:27 PM   #4
witchkinkofangmar
Member
 
Registered: May 2019
Posts: 83

Original Poster
Rep: Reputation: Disabled
Nice, thank you. I was using logrotate to compress and rotate so the directories don't get too big but I think your suggestion is much better:

Code:
/logs/sitename/*  {
    rotate 91
    daily
    compress
    missingok
    notifempty
    sharedscripts
    postrotate
        /usr/bin/killall -HUP httpd
    endscript
}
Code:
ErrorLog logs/domainname-error_log
CustomLog logs/domainname-access_log combined
Also, thanks for the link, that's exactly what I was looking for with ssl logs.
 
  


Reply

Tags
centos7, httpd, log files



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Enable logging of SSL URL's in squid access log vineethv Linux - Server 4 07-05-2018 06:03 AM
[SOLVED] Error on SVN checkout: SSL handshake failed: SSL error: Key usage violation in certif jsaravana87 Linux - Server 3 05-07-2012 10:00 AM
Problems with logging the output of a custom daemon with a custom init script d1s4st3r *BSD 3 04-30-2010 04:46 AM
[SOLVED] ssl.conf and multiple ssl certificastes on Apache kaoticsnow Linux - Server 22 04-08-2010 11:52 PM
SSL Servers vs Apache SSL mlewis Linux - Networking 2 04-02-2008 10:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration