Skip to content

Commit d074dc7

Browse files
committed
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
1 parent a90898d commit d074dc7

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

files/apache-keystone.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Listen %ADMINPORT%
66
WSGIProcessGroup keystone-public
77
WSGIScriptAlias / %PUBLICWSGI%
88
WSGIApplicationGroup %{GLOBAL}
9+
%ERRORLOGFORMAT%
910
ErrorLog /var/log/%APACHE_NAME%/keystone.log
1011
CustomLog /var/log/%APACHE_NAME%/access.log combined
1112
</VirtualHost>
@@ -15,6 +16,7 @@ Listen %ADMINPORT%
1516
WSGIProcessGroup keystone-admin
1617
WSGIScriptAlias / %ADMINWSGI%
1718
WSGIApplicationGroup %{GLOBAL}
19+
%ERRORLOGFORMAT%
1820
ErrorLog /var/log/%APACHE_NAME%/keystone.log
1921
CustomLog /var/log/%APACHE_NAME%/access.log combined
2022
</VirtualHost>

lib/apache

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,28 @@ function install_apache_wsgi {
6161
fi
6262
}
6363

64+
# get_apache_version() - return the version of Apache installed
65+
# This function is used to determine the Apache version installed. There are
66+
# various differences between Apache 2.2 and 2.4 that warrant special handling.
67+
function get_apache_version {
68+
if is_ubuntu; then
69+
local version_str=$(sudo /usr/sbin/apache2ctl -v | awk '/Server version/ {print $3}' | cut -f2 -d/)
70+
elif is_fedora; then
71+
local version_str=$(rpm -qa --queryformat '%{VERSION}' httpd)
72+
elif is_suse; then
73+
local version_str=$(rpm -qa --queryformat '%{VERSION}' apache2)
74+
else
75+
exit_distro_not_supported "cannot determine apache version"
76+
fi
77+
if [[ "$version_str" =~ ^2\.2\. ]]; then
78+
echo "2.2"
79+
elif [[ "$version_str" =~ ^2\.4\. ]]; then
80+
echo "2.4"
81+
else
82+
exit_distro_not_supported "apache version not supported"
83+
fi
84+
}
85+
6486
# apache_site_config_for() - The filename of the site's configuration file.
6587
# This function uses the global variables APACHE_NAME and APACHE_CONF_DIR.
6688
#
@@ -87,8 +109,8 @@ function install_apache_wsgi {
87109
function apache_site_config_for {
88110
local site=$@
89111
if is_ubuntu; then
90-
local apache_version=$(sudo /usr/sbin/apache2ctl -v | awk '/Server version/ {print $3}' | cut -f2 -d/)
91-
if [[ "$apache_version" =~ ^2\.2\. ]]; then
112+
local apache_version=$(get_apache_version)
113+
if [[ "$apache_version" == "2.2" ]]; then
92114
# Ubuntu 12.04 - Apache 2.2
93115
echo $APACHE_CONF_DIR/${site}
94116
else

lib/keystone

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ function _config_keystone_apache_wsgi {
123123
sudo mkdir -p $KEYSTONE_WSGI_DIR
124124

125125
local keystone_apache_conf=$(apache_site_config_for keystone)
126+
local apache_version=$(get_apache_version)
127+
128+
if [[ ${apache_version#*\.} -ge 4 ]]; then
129+
# Apache 2.4 supports custom error log formats
130+
# this should mirror the original log formatting.
131+
local errorlogformat='ErrorLogFormat "%{cu}t %M"'
132+
fi
126133

127134
# copy proxy vhost and wsgi file
128135
sudo cp $KEYSTONE_DIR/httpd/keystone.py $KEYSTONE_WSGI_DIR/main
@@ -136,6 +143,7 @@ function _config_keystone_apache_wsgi {
136143
s|%PUBLICWSGI%|$KEYSTONE_WSGI_DIR/main|g;
137144
s|%ADMINWSGI%|$KEYSTONE_WSGI_DIR/admin|g;
138145
s|%USER%|$STACK_USER|g
146+
s|%ERRORLOGFORMAT%|$errorlogformat|g;
139147
" -i $keystone_apache_conf
140148
enable_apache_site keystone
141149
}

0 commit comments

Comments
 (0)