CLIP-1800: Added maxDays in access log valve

This commit is contained in:
Jun Jeong 2023-05-16 16:20:29 +10:00
parent 07579a79aa
commit e50a7e685f
3 changed files with 16 additions and 1 deletions

View File

@ -141,6 +141,12 @@ see https://tomcat.apache.org/tomcat-7.0-doc/config/index.html
* `ATL_TOMCAT_URIENCODING` (default: UTF-8)
* `ATL_TOMCAT_MAXHTTPHEADERSIZE` (default: 8192)
## Access Log Settings
You can set the maximum number of days for access logs to be retained before being deleted. The default value of -1 means never delete old files.
* `ATL_TOMCAT_ACCESS_LOGS_MAXDAYS` (default: -1)
## JVM configuration
If you need to pass additional JVM arguments to Confluence such as specifying a

View File

@ -47,7 +47,8 @@
prefix="confluence_access"
suffix=".log"
rotatable="true"
pattern="%h %{X-AUSERNAME}o %t "%r" %s %b %D %U %I "%{User-Agent}i"" />
pattern="%h %{X-AUSERNAME}o %t "%r" %s %b %D %U %I "%{User-Agent}i""
maxDays="{{ atl_tomcat_access_logs_maxdays | default('-1') }}"/>
<Valve className="org.apache.catalina.valves.RemoteIpValve"
proxiesHeader="x-forwarded-by"
internalProxies="{{ atl_tomcat_proxy_internal_ips | default('') }}"

View File

@ -76,6 +76,8 @@ def test_server_xml_defaults(docker_cli, image):
xml = parse_xml(container, f'{get_app_install_dir(container)}/conf/server.xml')
connector = xml.find('.//Connector')
context = xml.find('.//Context')
valve = xml.find('.//Valve[@className="org.apache.catalina.valves.AccessLogValve"]')
assert connector.get('port') == '8090'
assert connector.get('maxThreads') == '48'
@ -95,6 +97,8 @@ def test_server_xml_defaults(docker_cli, image):
assert context.get('path') == ''
assert valve.get('maxDays') == '-1'
def test_server_xml_catalina_fallback(docker_cli, image):
environment = {
'CATALINA_CONNECTOR_PROXYNAME': 'PROXYNAME',
@ -136,6 +140,7 @@ def test_server_xml_params(docker_cli, image):
'ATL_PROXY_PORT': '443',
'ATL_TOMCAT_MAXHTTPHEADERSIZE': '8193',
'ATL_TOMCAT_CONTEXTPATH': '/myconf',
'ATL_TOMCAT_ACCESS_LOGS_MAXDAYS': '10',
}
container = run_image(docker_cli, image, environment=environment)
_jvm = wait_for_proc(container, get_bootstrap_proc(container))
@ -143,6 +148,7 @@ def test_server_xml_params(docker_cli, image):
xml = parse_xml(container, f'{get_app_install_dir(container)}/conf/server.xml')
connector = xml.find('.//Connector')
context = xml.find('.//Context')
valve = xml.find('.//Valve[@className="org.apache.catalina.valves.AccessLogValve"]')
assert xml.get('port') == environment.get('ATL_TOMCAT_MGMT_PORT')
@ -164,6 +170,8 @@ def test_server_xml_params(docker_cli, image):
assert context.get('path') == environment.get('ATL_TOMCAT_CONTEXTPATH')
assert valve.get('maxDays') == environment.get('ATL_TOMCAT_ACCESS_LOGS_MAXDAYS')
def test_server_xml_access_log_enabled(docker_cli, image):
environment = {
'ATL_TOMCAT_ACCESS_LOG': 'true',