0

I want to add the 'my_session' cookie value in the Apache error log. I have added an access log 'LogFormat' as below:

<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>

But when I add the same format in 'ErrorLogFormat' then face the error as Unrecognized error log format directive %C:

ErrorLogFormat "[%t] [%l] [pid %P] [%{my_session}C : %{UNIQUE_ID}e] [client %a] %M"

I used 'mod_unique_id' to get a unique request id.

My requirement is only to add SessionId value/Cookie value in Apache Error Log.

1 Answers1

0

So depending if the Cookie you want to log is in Request or Response heather you just use %{header_name}i or %{header_name}o respectively.

Daniel Ferradal
  • 2,415
  • 1
  • 8
  • 13