diff --git a/CHANGELOG.md b/CHANGELOG.md index acc7c8efa..8bb0ab056 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ - Open sockets with SO_REUSEPORT to allow multiple osrm-routed processes serving requests from the same port. - Add SIGNAL_PARENT_WHEN_READY environment variable to enable osrm-routed signal its parent with USR1 when it's running and waiting for requests. - BREAKING: Intersection Classification adds a new file to the mix (osrm.icd). This breaks the fileformat for older versions. + - Disable http access logging via DISABLE_ACCESS_LOGGING environment + variable. - Guidance: - improved detection of turning streets, not reporting new-name in wrong situations diff --git a/docs/http.md b/docs/http.md index 4c68bd640..338ab6485 100644 --- a/docs/http.md +++ b/docs/http.md @@ -7,6 +7,12 @@ send the USR1 signal to its parent when it will be running and waiting for requests. This could be used to upgrade osrm-routed to a new binary on the fly without any service downtime - no incoming requests will be lost. +### DISABLE_ACCESS_LOGGING + +If the DISABLE_ACCESS_LOGGING environment variable is set osrm-routed will +**not** log any http requests to standard output. This can be useful in high +traffic setup. + ## HTTP API `osrm-routed` supports only `GET` requests of the form. If you your response size diff --git a/src/server/request_handler.cpp b/src/server/request_handler.cpp index cfe74f257..026efd999 100644 --- a/src/server/request_handler.cpp +++ b/src/server/request_handler.cpp @@ -64,17 +64,20 @@ void RequestHandler::HandleRequest(const http::request ¤t_request, http::r ltime = time(nullptr); time_stamp = localtime(<ime); - // log timestamp - util::SimpleLogger().Write() - << (time_stamp->tm_mday < 10 ? "0" : "") << time_stamp->tm_mday << "-" - << (time_stamp->tm_mon + 1 < 10 ? "0" : "") << (time_stamp->tm_mon + 1) << "-" - << 1900 + time_stamp->tm_year << " " << (time_stamp->tm_hour < 10 ? "0" : "") - << time_stamp->tm_hour << ":" << (time_stamp->tm_min < 10 ? "0" : "") - << time_stamp->tm_min << ":" << (time_stamp->tm_sec < 10 ? "0" : "") - << time_stamp->tm_sec << " " << current_request.endpoint.to_string() << " " - << current_request.referrer << (0 == current_request.referrer.length() ? "- " : " ") - << current_request.agent << (0 == current_request.agent.length() ? "- " : " ") - << request_string; + if (!std::getenv("DISABLE_ACCESS_LOGGING")) + { + // log timestamp + util::SimpleLogger().Write() + << (time_stamp->tm_mday < 10 ? "0" : "") << time_stamp->tm_mday << "-" + << (time_stamp->tm_mon + 1 < 10 ? "0" : "") << (time_stamp->tm_mon + 1) << "-" + << 1900 + time_stamp->tm_year << " " << (time_stamp->tm_hour < 10 ? "0" : "") + << time_stamp->tm_hour << ":" << (time_stamp->tm_min < 10 ? "0" : "") + << time_stamp->tm_min << ":" << (time_stamp->tm_sec < 10 ? "0" : "") + << time_stamp->tm_sec << " " << current_request.endpoint.to_string() << " " + << current_request.referrer << (0 == current_request.referrer.length() ? "- " : " ") + << current_request.agent << (0 == current_request.agent.length() ? "- " : " ") + << request_string; + } auto api_iterator = request_string.begin(); auto maybe_parsed_url = api::parseURL(api_iterator, request_string.end());