Character encoding while logging custom log format in access log

Asked by manoj on 2017-08-31

I am using squid 4.0.21 with ecap version 1.0
I used to a custom access log format:
logformat customLogFormat %ts.%03tu %6tr %>a %ru %{status_info}adapt::<last_h

# TAG: access_log
access_log daemon:/usr/local/squid/var/logs/access.custom.log customLogFormat

ecap code for log the field %{status_info}adapt::<last_h is follows

string statusData;

/**
 *
 * @param visitor
 */
void RequestAction::visitEachOption(libecap::NamedValueVisitor &visitor) const {

    if(!statusData.empty()){
        visitor.visit(loggingStatus, Area(statusData.data(), statusData.size()));
    }
}
.
.
.
.

void RequestAction::start()
{
      /*
     some codes here
     */
                 statusData="12\\33\\testing";

                //pass the request as such.
  hostx->useVirgin();

}

But the squid access log is logged statusData as 12%5C33%5Ctesting instead of 12\33\testing
Squid logs the character '\' as %5C in access log. I need to log the filed %{status_info}adapt::<last_h as 12\33\testing

Could any one please help to resolve the issue

Question information

Language:
English Edit question
Status:
Solved
For:
eCAP Edit question
Assignee:
No assignee Edit question
Solved by:
Alex Rousskov
Solved:
2017-09-01
Last query:
2017-09-01
Last reply:
2017-08-31
Best Alex Rousskov (rousskov) said : #1

This is not a question about eCAP. This is a question about Squid. Please use Squid support channels for further assistance.

    http://www.squid-cache.org/Support/

Please also note that Squid logformat directive allows you to specify the encoding for most fields:

  % ["|[|'|#|/] [-] [[0]width] [{arg}] formatcode [{arg}]

  " output in quoted string format
  [ output in squid text log format as used by log_mime_hdrs
  # output in URL quoted format
  / output in shell \-escaped format
  ' output as-is

manoj (manojmaybe000) said : #2

Thanks Alex Rousskov, that solved my question.