class TomcatAccessLog {
- public static final String PROPERTY_ENABLE = "sonar.web.accessLogs.enable";
- public static final String PROPERTY_PATTERN = "sonar.web.accessLogs.pattern";
+ private static final String PROPERTY_ENABLE = "sonar.web.accessLogs.enable";
+ private static final String PROPERTY_PATTERN = "sonar.web.accessLogs.pattern";
+ private static final String DEFAULT_SQ_ACCESS_LOG_PATTERN = "%h %l %u [%t] \"%r\" %s %b \"%i{Referer}\" \"%i{User-Agent}\" \"%reqAttribute{ID}\"";
void configure(Tomcat tomcat, Props props) {
tomcat.setSilent(true);
FileAppender appender = policy.createAppender("ACCESS_LOG");
PatternLayoutEncoder fileEncoder = new PatternLayoutEncoder();
fileEncoder.setContext(valve);
- fileEncoder.setPattern(props.value(PROPERTY_PATTERN, "combined"));
+ fileEncoder.setPattern(props.value(PROPERTY_PATTERN, DEFAULT_SQ_ACCESS_LOG_PATTERN));
fileEncoder.start();
appender.setEncoder(fileEncoder);
appender.start();
# The value displayed for anonymous users is "-".
# The SonarQube's HTTP request ID can be added to the pattern with "%reqAttribute{ID}" (since version 6.2).
# If SonarQube is behind a reverse proxy, then the following value allows to display the correct remote IP address:
-#sonar.web.accessLogs.pattern=%i{X-Forwarded-For} %l %u [%t] "%r" %s %b "%i{Referer}" "%i{User-Agent}"
-# Default value is:
-#sonar.web.accessLogs.pattern=combined
+#sonar.web.accessLogs.pattern=%i{X-Forwarded-For} %l %u [%t] "%r" %s %b "%i{Referer}" "%i{User-Agent}" "%reqAttribute{ID}"
+# Default value (which was "combined" before version 6.2) is equivalent to "combined + SQ HTTP request ID":
+#sonar.web.accessLogs.pattern=%h %l %u [%t] "%r" %s %b "%i{Referer}" "%i{User-Agent}" "%reqAttribute{ID}"
#--------------------------------------------------------------------------------------------------
# AUTHENTICATION