diff --git a/CHANGELOG.md b/CHANGELOG.md index df064c3fa5..3dd5d1675d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - [#7153](https://github.com/apache/trafficcontrol/pull/7153) *Traffic Control Cache Config (t3c)* Adds an extra T3C check for validity of an ssl cert (crash fix). - [#3965](https://github.com/apache/trafficcontrol/pull/3965) *Traffic Router* Traffic Router now always includes a `Content-Length` header in the response. - [#7182](https://github.com/apache/trafficcontrol/pull/7182) Sort peers used in strategy.yaml to prevent false positive for reload. +- [#6533](https://github.com/apache/trafficcontrol/issues/6533) *TR should not rename/recreate log files on rollover ## [7.0.0] - 2022-07-19 ### Added diff --git a/docs/source/admin/traffic_router.rst b/docs/source/admin/traffic_router.rst index b640741d23..3d6aeb16f3 100644 --- a/docs/source/admin/traffic_router.rst +++ b/docs/source/admin/traffic_router.rst @@ -166,6 +166,8 @@ For the most part, the configuration files and :term:`Parameters` used by Traffi +----------------------------+-------------------------------------------+----------------------------------------------------------------------------------+----------------------------------------------------+ | log4j2.xml | various parameters | Configuration of ``log4j`` is documented on | N/A | | | | `their site `_; adjust as needed | | + | | | Log rotation is handled by logrotate. Relevant files are in /etc/logrotate.d and | | + | | | in /etc/cron.daily. | | +----------------------------+-------------------------------------------+----------------------------------------------------------------------------------+----------------------------------------------------+ | server.xml | various parameters | Traffic Router specific configuration for Apache Tomcat. See the Apache Tomcat | N/A | | | | `documentation `_ | | diff --git a/infrastructure/ansible/roles/traffic-router/files/traffic_router.logrotate b/infrastructure/ansible/roles/traffic-router/files/traffic_router.logrotate new file mode 100644 index 0000000000..cf6f862bd8 --- /dev/null +++ b/infrastructure/ansible/roles/traffic-router/files/traffic_router.logrotate @@ -0,0 +1,17 @@ +/opt/traffic_router/var/log/access.log { + daily + size 100m + compress + rotate 7 + dateformat -%d%m%Y + copytruncate +} + +/opt/traffic_router/var/log/traffic_router.log { + daily + size 100m + compress + rotate 7 + dateformat -%d%m%Y + copytruncate +} \ No newline at end of file diff --git a/infrastructure/ansible/roles/traffic-router/tasks/traffic_router.yml b/infrastructure/ansible/roles/traffic-router/tasks/traffic_router.yml index b23314454b..e8f6490226 100644 --- a/infrastructure/ansible/roles/traffic-router/tasks/traffic_router.yml +++ b/infrastructure/ansible/roles/traffic-router/tasks/traffic_router.yml @@ -94,6 +94,15 @@ become: yes register: tr_systemd +- name: Copy traffic router logrotate file + file: + src: traffic_router.logrotate + dest: /etc/logrotate.d/traffic_router + mode: 0644 + owner: root + group: root + become: yes + - name: Reload systemd unit files if needed systemd: daemon_reload: yes diff --git a/traffic_router/build/build_rpm.sh b/traffic_router/build/build_rpm.sh index 56079e5847..f624f44906 100755 --- a/traffic_router/build/build_rpm.sh +++ b/traffic_router/build/build_rpm.sh @@ -39,6 +39,8 @@ buildRpmTrafficRouter () { export STARTUP_SCRIPT_DIR="/lib/systemd/system" export STARTUP_SCRIPT_LOC="../core/src/main/lib/systemd/system" + export LOGROTATE_SCRIPT_DIR="/etc/logrotate.d" + export LOGROTATE_SCRIPT_LOC="../core/src/main/lib/logrotate" cd "$TR_DIR" || { echo "Could not cd to $TR_DIR: $?"; return 1; } mvn -P rpm-build -Dmaven.test.skip=true -DminimumTPS=1 clean package || \ diff --git a/traffic_router/build/pom.xml b/traffic_router/build/pom.xml index 42ecedb639..5ee9f7dc38 100644 --- a/traffic_router/build/pom.xml +++ b/traffic_router/build/pom.xml @@ -208,6 +208,18 @@ + + ${env.LOGROTATE_SCRIPT_DIR} + false + 644 + root + root + + + ${env.LOGROTATE_SCRIPT_LOC} + + + ${deploy.dir}/webapps false diff --git a/traffic_router/core/src/main/conf/log4j2.xml b/traffic_router/core/src/main/conf/log4j2.xml index 5984d9d0e4..760eefdff7 100644 --- a/traffic_router/core/src/main/conf/log4j2.xml +++ b/traffic_router/core/src/main/conf/log4j2.xml @@ -13,41 +13,30 @@ See the License for the specific language governing permissions and limitations under the License. --> - + + - - - - - - - - - - - - - - - - + + + + + + + + + + + - - - diff --git a/traffic_router/core/src/main/lib/logrotate/traffic_router b/traffic_router/core/src/main/lib/logrotate/traffic_router new file mode 100644 index 0000000000..2604d09a8b --- /dev/null +++ b/traffic_router/core/src/main/lib/logrotate/traffic_router @@ -0,0 +1,17 @@ +/opt/traffic_router/var/log/access.log { + daily + size 1k + compress + rotate 7 + dateformat -%d%m%Y + copytruncate +} + +/opt/traffic_router/var/log/traffic_router.log { + daily + size 1k + compress + rotate 7 + dateformat -%d%m%Y + copytruncate +} \ No newline at end of file