Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
71df2f31
Commit
71df2f31
authored
Feb 14, 2019
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Expose Tomcat AccessLog Max days property"
Closes gh-15954
parent
596f0c28
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
25 deletions
+26
-25
ServerProperties.java
...ingframework/boot/autoconfigure/web/ServerProperties.java
+14
-14
TomcatWebServerFactoryCustomizer.java
...figure/web/embedded/TomcatWebServerFactoryCustomizer.java
+2
-2
TomcatWebServerFactoryCustomizerTests.java
...e/web/embedded/TomcatWebServerFactoryCustomizerTests.java
+9
-8
application-properties.adoc
...cs/src/main/asciidoc/appendix/application-properties.adoc
+1
-1
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java
View file @
71df2f31
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -593,6 +593,11 @@ public class ServerProperties {
*/
private
boolean
renameOnRotate
=
false
;
/**
* Number of days to retain the access log files before they are removed.
*/
private
int
maxDays
=
-
1
;
/**
* Date format to place in the log file name.
*/
...
...
@@ -609,19 +614,6 @@ public class ServerProperties {
*/
private
boolean
buffered
=
true
;
/**
* The number of days to retain the access log files before they are removed.
*/
private
int
maxDays
=
-
1
;
public
int
getMaxDays
()
{
return
this
.
maxDays
;
}
public
void
setMaxDays
(
int
maxDays
)
{
this
.
maxDays
=
maxDays
;
}
public
boolean
isEnabled
()
{
return
this
.
enabled
;
}
...
...
@@ -678,6 +670,14 @@ public class ServerProperties {
this
.
renameOnRotate
=
renameOnRotate
;
}
public
int
getMaxDays
()
{
return
this
.
maxDays
;
}
public
void
setMaxDays
(
int
maxDays
)
{
this
.
maxDays
=
maxDays
;
}
public
String
getFileDateFormat
()
{
return
this
.
fileDateFormat
;
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java
View file @
71df2f31
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -258,12 +258,12 @@ public class TomcatWebServerFactoryCustomizer implements
valve
.
setPrefix
(
tomcatProperties
.
getAccesslog
().
getPrefix
());
valve
.
setSuffix
(
tomcatProperties
.
getAccesslog
().
getSuffix
());
valve
.
setRenameOnRotate
(
tomcatProperties
.
getAccesslog
().
isRenameOnRotate
());
valve
.
setMaxDays
(
tomcatProperties
.
getAccesslog
().
getMaxDays
());
valve
.
setFileDateFormat
(
tomcatProperties
.
getAccesslog
().
getFileDateFormat
());
valve
.
setRequestAttributesEnabled
(
tomcatProperties
.
getAccesslog
().
isRequestAttributesEnabled
());
valve
.
setRotatable
(
tomcatProperties
.
getAccesslog
().
isRotate
());
valve
.
setBuffered
(
tomcatProperties
.
getAccesslog
().
isBuffered
());
valve
.
setMaxDays
(
tomcatProperties
.
getAccesslog
().
getMaxDays
());
factory
.
addEngineValves
(
valve
);
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java
View file @
71df2f31
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -326,20 +326,21 @@ public class TomcatWebServerFactoryCustomizerTests {
}
@Test
public
void
accessLogSetMaxDays
()
{
bind
(
"server.tomcat.accesslog.enabled=true"
,
"server.tomcat.accesslog.max-days=20"
);
public
void
accessLogMaxDaysDefault
()
{
bind
(
"server.tomcat.accesslog.enabled=true"
);
TomcatServletWebServerFactory
factory
=
customizeAndGetFactory
();
assertThat
(((
AccessLogValve
)
factory
.
getEngineValves
().
iterator
().
next
())
.
getMaxDays
()).
isEqualTo
(
20
);
.
getMaxDays
()).
isEqualTo
(
this
.
serverProperties
.
getTomcat
().
getAccesslog
().
getMaxDays
());
}
@Test
public
void
accessLogDefaultMaxDays
()
{
bind
(
"server.tomcat.accesslog.enabled=true"
);
public
void
accessLoMaxDaysCanBeRedefined
()
{
bind
(
"server.tomcat.accesslog.enabled=true"
,
"server.tomcat.accesslog.max-days=20"
);
TomcatServletWebServerFactory
factory
=
customizeAndGetFactory
();
assertThat
(((
AccessLogValve
)
factory
.
getEngineValves
().
iterator
().
next
())
.
getMaxDays
()).
isEqualTo
(
-
1
);
.
getMaxDays
()).
isEqualTo
(
20
);
}
private
void
bind
(
String
...
inlinedProperties
)
{
...
...
spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix/application-properties.adoc
View file @
71df2f31
...
...
@@ -255,7 +255,7 @@ content into your application. Rather, pick only the properties that you need.
server.tomcat.accesslog.directory=logs # Directory in which log files are created. Can be absolute or relative to the Tomcat base dir.
server.tomcat.accesslog.enabled=false # Enable access log.
server.tomcat.accesslog.file-date-format=.yyyy-MM-dd # Date format to place in the log file name.
server.tomcat.accesslog.max-days=-1#
The n
umber of days to retain the access log files before they are removed.
server.tomcat.accesslog.max-days=-1#
N
umber of days to retain the access log files before they are removed.
server.tomcat.accesslog.pattern=common # Format pattern for access logs.
server.tomcat.accesslog.prefix=access_log # Log file name prefix.
server.tomcat.accesslog.rename-on-rotate=false # Whether to defer inclusion of the date stamp in the file name until rotate time.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment