
Ich möchte den Cookie-Wert „my_session“ zum Apache-Fehlerprotokoll hinzufügen. Ich habe ein Zugriffsprotokoll „LogFormat“ wie folgt hinzugefügt:
<IfModule mod_ssl.c>
<VirtualHost *:443>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" [%{my_session}C : %{UNIQUE_ID}e]" detailed
CustomLog ${APACHE_LOG_DIR}/ssl.www.example.com_access.log detailed
ErrorLogFormat "[%t] [%l] [pid %P] [%{UNIQUE_ID}e] [client %a] %M"
ErrorLog ${APACHE_LOG_DIR}/ssl.www.example.com_error.log
</VirtualHost>
</IfModule>
Wenn ich jedoch dasselbe Format in „ErrorLogFormat“ hinzufüge, wird der Fehler „Unbekannte Fehlerprotokollformatanweisung %C“ angezeigt:
ErrorLogFormat "[%t] [%l] [pid %P] [%{my_session}C : %{UNIQUE_ID}e] [client %a] %M"
Ich habe „mod_unique_id“ verwendet, um eine eindeutige Anforderungs-ID zu erhalten.
Meine Anforderung besteht lediglich darin, den SessionId-Wert/Cookie-Wert im Apache-Fehlerprotokoll hinzuzufügen.
Antwort1
Je nachdem, ob das Cookie, das Sie protokollieren möchten, in Request oder Response Heather ist, verwenden Sie einfach%{header_name}ichoder%{header_name}ojeweils.
Antwort2
Dies ist ein Auszug aus meiner httpd.conf-Datei, die ich gerade verwende.
LogFormat "%r \"%{Cookie}i\"" combined