Use the apache 2.4 ErrorLogFormat directive

Use the new ErrorLogFormat directive to make the Keystone logs
under Apache to look like the standard oslo log format.

Change-Id: Ie823abf2fa06b8ce22027c21bef455808a4a768e
This commit is contained in:
Morgan Fainberg 2014-06-24 21:33:39 -07:00
parent a90898d904
commit d074dc7f7e
3 changed files with 34 additions and 2 deletions

View File

@ -6,6 +6,7 @@ Listen %ADMINPORT%
WSGIProcessGroup keystone-public
WSGIScriptAlias / %PUBLICWSGI%
WSGIApplicationGroup %{GLOBAL}
%ERRORLOGFORMAT%
ErrorLog /var/log/%APACHE_NAME%/keystone.log
CustomLog /var/log/%APACHE_NAME%/access.log combined
</VirtualHost>
@ -15,6 +16,7 @@ Listen %ADMINPORT%
WSGIProcessGroup keystone-admin
WSGIScriptAlias / %ADMINWSGI%
WSGIApplicationGroup %{GLOBAL}
%ERRORLOGFORMAT%
ErrorLog /var/log/%APACHE_NAME%/keystone.log
CustomLog /var/log/%APACHE_NAME%/access.log combined
</VirtualHost>

View File

@ -61,6 +61,28 @@ function install_apache_wsgi {
fi
}
# get_apache_version() - return the version of Apache installed
# This function is used to determine the Apache version installed. There are
# various differences between Apache 2.2 and 2.4 that warrant special handling.
function get_apache_version {
if is_ubuntu; then
local version_str=$(sudo /usr/sbin/apache2ctl -v | awk '/Server version/ {print $3}' | cut -f2 -d/)
elif is_fedora; then
local version_str=$(rpm -qa --queryformat '%{VERSION}' httpd)
elif is_suse; then
local version_str=$(rpm -qa --queryformat '%{VERSION}' apache2)
else
exit_distro_not_supported "cannot determine apache version"
fi
if [[ "$version_str" =~ ^2\.2\. ]]; then
echo "2.2"
elif [[ "$version_str" =~ ^2\.4\. ]]; then
echo "2.4"
else
exit_distro_not_supported "apache version not supported"
fi
}
# apache_site_config_for() - The filename of the site's configuration file.
# This function uses the global variables APACHE_NAME and APACHE_CONF_DIR.
#
@ -87,8 +109,8 @@ function install_apache_wsgi {
function apache_site_config_for {
local site=$@
if is_ubuntu; then
local apache_version=$(sudo /usr/sbin/apache2ctl -v | awk '/Server version/ {print $3}' | cut -f2 -d/)
if [[ "$apache_version" =~ ^2\.2\. ]]; then
local apache_version=$(get_apache_version)
if [[ "$apache_version" == "2.2" ]]; then
# Ubuntu 12.04 - Apache 2.2
echo $APACHE_CONF_DIR/${site}
else

View File

@ -123,6 +123,13 @@ function _config_keystone_apache_wsgi {
sudo mkdir -p $KEYSTONE_WSGI_DIR
local keystone_apache_conf=$(apache_site_config_for keystone)
local apache_version=$(get_apache_version)
if [[ ${apache_version#*\.} -ge 4 ]]; then
# Apache 2.4 supports custom error log formats
# this should mirror the original log formatting.
local errorlogformat='ErrorLogFormat "%{cu}t %M"'
fi
# copy proxy vhost and wsgi file
sudo cp $KEYSTONE_DIR/httpd/keystone.py $KEYSTONE_WSGI_DIR/main
@ -136,6 +143,7 @@ function _config_keystone_apache_wsgi {
s|%PUBLICWSGI%|$KEYSTONE_WSGI_DIR/main|g;
s|%ADMINWSGI%|$KEYSTONE_WSGI_DIR/admin|g;
s|%USER%|$STACK_USER|g
s|%ERRORLOGFORMAT%|$errorlogformat|g;
" -i $keystone_apache_conf
enable_apache_site keystone
}