Skip to content

Commit

Permalink
Issue 51098: Update embedded Tomcat HTTP access logging to capture tr…
Browse files Browse the repository at this point in the history
…ue client IP (#872)
  • Loading branch information
labkey-jeckels authored Sep 3, 2024
1 parent a03311f commit daa2201
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 4 additions & 4 deletions server/configs/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ management.server.port=@@shutdownPort@@

## Optional configuration, modeled on the non-JSON Spring Boot properties
## https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html#application-properties.server.server.tomcat.accesslog.buffered
#jsonaccesslog.pattern=%h %t %m %U %s %b %D %S "%{Referer}i" "%{User-Agent}i" %{LABKEY.username}s
#jsonaccesslog.pattern=%h %t %m %U %s %b %D %S "%{Referer}i" "%{User-Agent}i" %{LABKEY.username}s %{X-Forwarded-For}i
#jsonaccesslog.condition-if=attributeName
#jsonaccesslog.condition-unless=attributeName

Expand Down Expand Up @@ -174,6 +174,6 @@ csp.report=\
## Use a custom logging configuration
#logging.config=path/to/alternative/log4j2.xml

## Enable tomcat access log
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %S %I "%{Referrer}i" "%{User-Agent}i" %{LABKEY.username}s
## File-based Tomcat HTTP access logs are enabled by default and use our recommended pattern. Override as needed.
#server.tomcat.accesslog.enabled=false
#server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %S %I "%{Referrer}i" "%{User-Agent}i" %{LABKEY.username}s %{X-Forwarded-For}i
8 changes: 6 additions & 2 deletions server/embedded/src/org/labkey/embedded/LabKeyServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@ public static void main(String[] args)
"server.tomcat.accesslog.directory", logHome,

// Enable HTTP compression for response content
"server.compression.enabled", "true"
));
"server.compression.enabled", "true",

"server.tomcat.accesslog.enabled", "true",
"server.tomcat.accesslog.pattern", "%h %l %u %t \"%r\" %s %b %D %S %I \"%{Referrer}i\" \"%{User-Agent}i\" %{LABKEY.username}s %{X-Forwarded-For}i",
"jsonaccesslog.pattern", "%h %t %m %U %s %b %D %S \"%{Referer}i\" \"%{User-Agent}i\" %{LABKEY.username}s %{X-Forwarded-For}i"
));
application.setBannerMode(Banner.Mode.OFF);
application.run(args);
}
Expand Down

0 comments on commit daa2201

Please sign in to comment.