Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 6533 #7234

Merged
merged 5 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docs/source/admin/traffic_router.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <http://logging.apache.org/log4j/2.x/index.html>`_; 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 <https://tomcat.apache.org/tomcat-9.0-doc/index.html>`_ | |
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions traffic_router/build/build_rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 || \
Expand Down
12 changes: 12 additions & 0 deletions traffic_router/build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,18 @@
</source>
</sources>
</mapping>
<mapping>
<directory>${env.LOGROTATE_SCRIPT_DIR}</directory>
<directoryIncluded>false</directoryIncluded>
<filemode>644</filemode>
<username>root</username>
<groupname>root</groupname>
<sources>
<source>
<location>${env.LOGROTATE_SCRIPT_LOC}</location>
</source>
</sources>
</mapping>
<mapping>
<directory>${deploy.dir}/webapps</directory>
<directoryIncluded>false</directoryIncluded>
Expand Down
37 changes: 13 additions & 24 deletions traffic_router/core/src/main/conf/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,30 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<Configuration>
<!-- file deployed via ansible push, local edits are subject to be overwritten -->
<Configuration packages="org.apache.trafficrouter.trafficrouterappender" verbose="true">
<Appenders>
<Console name="stdout" target="SYSTEM_OUT">
<PatternLayout pattern="%m%n" />
</Console>
<RollingFile name="traffic_router_access"
fileName="${deploy.dir}/var/log/access.log"
filePattern="${deploy.dir}/var/log/access.log.%i" >
<PatternLayout pattern="%m%n" />
<Policies>
<SizeBasedTriggeringPolicy size="200MB" />
</Policies>
<DefaultRolloverStrategy max="10" />
<ThresholdFilter level="INFO" />
</RollingFile>
<RollingFile name="traffic_router"
fileName="${deploy.dir}/var/log/traffic_router.log"
filePattern="${deploy.dir}/var/log/traffic_router.log.%i" >
<PatternLayout pattern="%-5p %d{yyyy-MM-dd'T'HH:mm:ss.SSS} [%t] %c - %m%n" />
<Policies>
<SizeBasedTriggeringPolicy size="100MB" />
</Policies>
<DefaultRolloverStrategy max="1" />
<ThresholdFilter level="ALL" />
</RollingFile>
<File name="traffic_router" fileName="/opt/traffic_router/var/log/traffic_router.log" immediateFlush="true" append="true">
<PatternLayout pattern="%-5p %d{yyyy-MM-dd'T'HH:mm:ss.SSS} [%t] %c - %m%n" />
<ThresholdFilter level="ALL" />
</File>
<File name="traffic_router_access" fileName="/opt/traffic_router/var/log/access.log" immediateFlush="true" append="true">
<PatternLayout pattern="%m%n" />
<ThresholdFilter level="INFO" />
</File>
</Appenders>
<Loggers>
<Root level="WARN" additivity="false" >
<AppenderRef ref="stdout" />
</Root>
<Logger name="org.apache.traffic_control.traffic_router" level="INFO" additivity="false" >
<AppenderRef ref="traffic_router" />
</Logger>
<Logger name="org.apache.traffic_control.traffic_router.core.access" level="INFO" additivity="false" >
<AppenderRef ref="traffic_router_access" />
</Logger>
<Root level="WARN" additivity="false" >
<AppenderRef ref="stdout" />
</Root>
</Loggers>
</Configuration>
17 changes: 17 additions & 0 deletions traffic_router/core/src/main/lib/logrotate/traffic_router
Original file line number Diff line number Diff line change
@@ -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
}