]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8332 change default access log pattern to include SQ's HTTP request ID 1399/head
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 17 Nov 2016 14:57:24 +0000 (15:57 +0100)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 17 Nov 2016 16:59:44 +0000 (17:59 +0100)
server/sonar-server/src/main/java/org/sonar/server/app/TomcatAccessLog.java
sonar-application/src/main/assembly/conf/sonar.properties

index 54e893240bde0997b19bc345e0e7c379986cf79a..18792c1676f3e7facb1d08502e2f2541a2878376 100644 (file)
@@ -31,8 +31,9 @@ import org.sonar.process.Props;
 
 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);
@@ -48,7 +49,7 @@ class TomcatAccessLog {
       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();
index a1f0194ba0eae2c0f0798128f67434a69ab9ab45..27b487638c8f386fcb2360f5a7da84a77d9bd918 100644 (file)
 # 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