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

Updated log4j from version 1.2.17 to version 2.16.0 #6390

Merged
merged 34 commits into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8c7b247
updated log4j from version 1 to 2
rimashah25 Dec 1, 2021
6631e35
Updated pom.xml to include pom type tag
rimashah25 Dec 2, 2021
65d1d90
Updated pom.xml to remove pom type tag and use log4j-core artifactID.
rimashah25 Dec 2, 2021
d491d7e
Updated java files to use LogManager class instead of logger class fo…
rimashah25 Dec 2, 2021
6df92f2
Updated java files to use LogManager class instead of logger class fo…
rimashah25 Dec 2, 2021
70f96b7
Un-optimized import statements
rimashah25 Dec 2, 2021
b9fe80a
Updated setLevel class for getLogger and getRootLogger.
rimashah25 Dec 2, 2021
c64627f
Updated setLevel class for getLogger and getRootLogger-1
rimashah25 Dec 2, 2021
22289f1
Imported Record class from Maven to remove ambiguity.
rimashah25 Dec 3, 2021
ecf0e13
Revert "Imported Record class from Maven to remove ambiguity."
rimashah25 Dec 3, 2021
00d9b3d
Fixed when clause with LogManager.
rimashah25 Dec 3, 2021
bd930af
Fixed when clause with LogManager-1
rimashah25 Dec 3, 2021
411bb52
updated CHANGELOG.md
rimashah25 Dec 3, 2021
dec8514
Merge branch 'master' of github.com:apache/trafficcontrol into upgrad…
rimashah25 Dec 6, 2021
5d68e7c
Fixed based on review comments
rimashah25 Dec 6, 2021
0ff59c3
Fixed based on review comments - 1
rimashah25 Dec 6, 2021
bae3848
updated import path for ConsoleAppender, PatternLayout, RollingFileAp…
rimashah25 Dec 6, 2021
8ce7b68
updated log4j version to 2.15.0
rimashah25 Dec 10, 2021
0d8863a
Merge branch 'master' of github.com:apache/trafficcontrol into upgrad…
rimashah25 Dec 10, 2021
9568654
Added slf4j-simple dependency.
rimashah25 Dec 10, 2021
c97b6ad
removed file:// to log INFO level messages.
rimashah25 Dec 10, 2021
645e8ed
removed file:// to log INFO level messages-1
rimashah25 Dec 10, 2021
0878810
Migrated log4j properties to log4j2.xml
rimashah25 Dec 14, 2021
d834ec8
Updated log4j to version 2.16.0
rimashah25 Dec 14, 2021
79ef73d
added fileName property
rimashah25 Dec 14, 2021
f1dcd82
Updated date format based on review comments.
rimashah25 Dec 14, 2021
38276ff
Added new line for xml files.
rimashah25 Dec 14, 2021
4ccf685
Added AppenderRef for traffic_router.log, access.log and console.
rimashah25 Dec 14, 2021
5bf4de4
Removed typo character and fixed xml tags.
rimashah25 Dec 15, 2021
6eb1123
Updated log4j in ansible.
rimashah25 Dec 15, 2021
a14f1e6
Updated based on review comments.
rimashah25 Dec 15, 2021
9a1ab1c
Added threshold level to main.yml and log4j2.xml
rimashah25 Dec 16, 2021
5366136
Added PatternLayout level to main.yml
rimashah25 Dec 16, 2021
ae390b1
Added additivity="false" to avoid printing logs twice
rimashah25 Dec 16, 2021
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 @@ -39,6 +39,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- [#6367](https://github.com/apache/trafficcontrol/issues/6367) - Fix PUT `user/current` to work with v4 User Roles and Permissions

### Changed
- Updated `log4j` module in Traffic Router from version 1.2.17 to 2.16.0
- Updated `t3c` to request less unnecessary deliveryservice-server assignment and invalidation jobs data via new query params supported by Traffic Ops
- [#6179](https://github.com/apache/trafficcontrol/issues/6179) Updated the Traffic Ops rpm to include the `ToDnssecRefresh` binary and make the `trafops_dnssec_refresh` cron job use it
- Changed the DNSSEC refresh Traffic Ops API to only create a new change log entry if any keys were actually refreshed or an error occurred (in order to reduce changelog noise)
Expand Down
10 changes: 5 additions & 5 deletions docs/source/admin/traffic_router.rst
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ For the most part, the configuration files and :term:`Parameters` used by Traffi
| | | when the ``traffic_router`` service is started. It primarily consists of command | |
| | | line settings for the Java process | |
+----------------------------+-------------------------------------------+----------------------------------------------------------------------------------+----------------------------------------------------+
| log4j.properties | various parameters | Configuration of ``log4j`` is documented on | N/A |
| 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 | |
+----------------------------+-------------------------------------------+----------------------------------------------------------------------------------+----------------------------------------------------+
| server.xml | various parameters | Traffic Router specific configuration for Apache Tomcat. See the Apache Tomcat | N/A |
Expand All @@ -189,11 +189,11 @@ Much of a Traffic Router's configuration can be obtained through the :term:`Para
+=========================================+==============================+=======================================================================================================================================+
| location | dns.zone | Location to store the DNS zone files in the local file system of Traffic Router. |
+-----------------------------------------+------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
| location | http-log4j.properties | Location to find the log4j.properties file for Traffic Router. |
| location | http-log4j2.xml | Location to find the log4j2.xml file for Traffic Router. |
+-----------------------------------------+------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
| location | dns-log4j.properties | Location to find the dns-log4j.properties file for Traffic Router. |
| location | dns-log4j2.xml | Location to find the dns-log4j2.xml file for Traffic Router. |
+-----------------------------------------+------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
| location | geolocation.properties | Location to find the log4j.properties file for Traffic Router. |
| location | geolocation.properties | Location to find the log4j2.xml file for Traffic Router. |
+-----------------------------------------+------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
| CDN_name | rascal-config.txt | The human readable name of the CDN for this :term:`Profile`. |
+-----------------------------------------+------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
Expand Down Expand Up @@ -944,7 +944,7 @@ The following is an example of the command line parameters set in :file:`/opt/tr

CATALINA_OPTS="\
-server -Xms2g -Xmx8g \
-Dlog4j.configuration=file://$CATALINA_BASE/conf/log4j.properties \
-Dlog4j.configurationFile=$CATALINA_BASE/conf/log4j2.xml \
-Djava.library.path=/usr/lib64 \
-XX:+UseG1GC \
-XX:+UnlockExperimentalVMOptions \
Expand Down
2 changes: 1 addition & 1 deletion docs/source/development/traffic_router.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ To install the Traffic Router Developer environment:

* copy :file:`core/src/main/conf/dns.properties` to :file:`core/src/test/conf/`
* copy :file:`core/src/main/conf/http.properties` to :file:`core/src/test/conf/`
* copy :file:`core/src/main/conf/log4j.properties` to :file:`core/src/test/conf/`
* copy :file:`core/src/main/conf/log4j2.xml` to :file:`core/src/test/conf/`
* copy :file:`core/src/main/conf/traffic_monitor.properties` to :file:`core/src/test/conf/` and then edit the ``traffic_monitor.bootstrap.hosts`` property
* copy :file:`core/src/main/conf/traffic_ops.properties` to :file:`core/src/test/conf/` and then edit the credentials as appropriate for the Traffic Ops instance you will be using.
* Default configuration values now reside in :file:`core/src/main/webapp/WEB-INF/applicationContext.xml`
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/ansible/roles/traffic-router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Example Playbook
- "-server"
- "-Xms2g"
- "-Xmx{{ [(ansible_memtotal_mb * (tr_java_heap_max_percent/100))|int, tr_java_heap_max_mb]|min }}m"
- "-Dlog4j.configuration=file://$CATALINA_BASE/conf/log4j.properties"
- "-Dlog4j.configurationFile=$CATALINA_BASE/conf/log4j2.xml"
- "-Djava.library.path=/usr/lib64"
- "-Dorg.apache.catalina.connector.Response.ENFORCE_ENCODING_IN_GET_WRITER=false"
- "-XX:+UseG1GC"
Expand Down
68 changes: 37 additions & 31 deletions infrastructure/ansible/roles/traffic-router/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ tr_catalina_opts:
- "-server"
- "-Xms2g"
- "-Xmx{{ [(ansible_memtotal_mb * (tr_java_heap_max_percent/100))|int, tr_java_heap_max_mb]|min }}m"
- "-Dlog4j.configuration=file://$CATALINA_BASE/conf/log4j.properties"
- "-Dlog4j.configurationFile=$CATALINA_BASE/conf/log4j2.xml"
- "-Djava.library.path=/usr/lib64"
- "-Dorg.apache.catalina.connector.Response.ENFORCE_ENCODING_IN_GET_WRITER=false"
- "-XX:+UseG1GC"
Expand Down Expand Up @@ -126,36 +126,42 @@ tr_cache_health_json_refresh_period: 1000
tr_cache_config_json: "{{tr_db_dir}}/cr-config.json"
tr_cache_config_json_refresh_period: 60000

# log4j.properties
tr_log4j_opts:
- "# ACCESS is set to be a Syslog Appender"
- log4j.appender.ACCESS=org.apache.log4j.RollingFileAppender
- "log4j.appender.ACCESS.File={{tr_log_dir}}/access.log"
- log4j.appender.ACCESS.MaxFileSize=200MB
- log4j.appender.ACCESS.MaxBackupIndex=10
-
- "# ACCESS uses PatternLayout."
- log4j.appender.ACCESS.layout=org.apache.log4j.PatternLayout
- log4j.appender.ACCESS.layout.ConversionPattern=%m%n
- log4j.appender.ACCESS.threshold=INFO
-
- log4j.appender.A1=org.apache.log4j.RollingFileAppender
- "log4j.appender.A1.file={{tr_log_dir}}/traffic_router.log"
- log4j.appender.A1.maxFileSize=100MB
-
- "# A1 uses PatternLayout."
- log4j.appender.A1.layout=org.apache.log4j.PatternLayout
- log4j.appender.A1.layout.ConversionPattern=%-5p %d{yyyy-MM-dd'T'HH:mm:ss.SSS} [%t] %c - %m%n
- log4j.appender.A1.threshold=ALL
-
- "# Set root logger level to DEBUG and its only appender to A1."
- "# Valid levels are: ALL, TRACE, DEBUG, INFO, WARN, ERROR, FATAL, NONE"
- log4j.rootLogger=WARN, A1
-
- "# Set application logger levels"
- log4j.logger.org.apache.traffic_control.traffic_router=INFO
- log4j.logger.org.apache.traffic_control.traffic_router.core.access=INFO, ACCESS
- log4j.additivity.org.apache.traffic_control.traffic_router.core.access=false
# log4j2.xml
tr_log4j2_opts: |
<Configuration>
<Appenders>
<Console name="stdout" target="SYSTEM_OUT">
<PatternLayout pattern="%m%n" />
</Console>
<RollingFile name="traffic_router_access"
fileName="{{tr_log_dir}}/access.log"
filePattern="{{tr_log_dir}}/access-%d{yyyy-MM-dd}.log" >
<PatternLayout pattern="%m%n" />
<Policies>
<SizeBasedTriggeringPolicy size="200MB" />
</Policies>
<DefaultRolloverStrategy max="10" />
</RollingFile>
<RollingFile name="traffic_router"
fileName="{{tr_log_dir}}/traffic_router.log"
filePattern="{{tr_log_dir}}/traffic_router-%d{yyyy-MM-dd}.log" >
<Policies>
zrhoffman marked this conversation as resolved.
Show resolved Hide resolved
<SizeBasedTriggeringPolicy size="100MB" />
</Policies>
</RollingFile>
</Appenders>
<Loggers>
<Logger name="org.apache.traffic_control.traffic_router" level="INFO" >
<AppenderRef ref="traffic_router" />
</Logger>
<Logger name="org.apache.traffic_control.traffic_router.core.access" level="INFO" >
<AppenderRef ref="traffic_router_access" />
</Logger>
<Root level="WARN" additivity="false" >
<AppenderRef ref="stdout" />
</Root>
</Loggers>
</Configuration>

# logging.properties
tr_logging_opts:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
with_items:
- cache.properties
- dns.properties
- log4j.properties
- log4j2.xml
- logging.properties
- startup.properties
- traffic_monitor.properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,4 @@
#}
rimashah25 marked this conversation as resolved.
Show resolved Hide resolved
# file deployed via ansible push, local edits are subject to be overwritten

{% for line in tr_log4j_opts %}
{{ line }}
{% endfor %}
{{ tr_log4j2_opts }}
2 changes: 1 addition & 1 deletion infrastructure/cdn-in-a-box/traffic_router/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ CATALINA_PID="$CATALINA_BASE/temp/tomcat.pid"
CATALINA_OPTS="\
-server -Xms2g -Xmx8g \
-Djava.library.path=/usr/lib64:$CATALINA_BASE/lib:$CATALINA_HOME/lib \
-Dlog4j.configuration=file://$CATALINA_BASE/conf/log4j.properties \
-Dlog4j.configurationFile=$CATALINA_BASE/conf/log4j2.xml \
-Dorg.apache.catalina.connector.Response.ENFORCE_ENCODING_IN_GET_WRITER=false \
-XX:+UseG1GC \
-XX:+UnlockExperimentalVMOptions \
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/docker/traffic_router/starttr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export CATALINA_BASE=/opt/traffic_router
export CATALINA_OUT=/opt/tomcat/logs/catalina.log
export CATALINA_OPTS="\
-server -Xms512m -Xmx1g \
-Dlog4j.configuration=file://$CATALINA_BASE/conf/log4j.properties \
-Dlog4j.configurationFile=$CATALINA_BASE/conf/log4j2.xml \
-Djava.library.path=/usr/lib64 \
-Dorg.apache.catalina.connector.Response.ENFORCE_ENCODING_IN_GET_WRITER=false \
-XX:+UseG1GC \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@

package org.apache.traffic_control.traffic_router.protocol;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.lang.management.ManagementFactory;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import java.lang.management.ManagementFactory;

public class LanguidPoller extends Thread {
private static final Logger log = Logger.getLogger(LanguidPoller.class);
private static final Logger log = LogManager.getLogger(LanguidPoller.class);
final private RouterProtocolHandler protocolHandler;

public LanguidPoller(final RouterProtocolHandler protocolHandler) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@


import org.apache.coyote.http11.Http11NioProtocol;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class LanguidProtocol extends Http11NioProtocol implements RouterProtocolHandler {
private static final Logger log = Logger.getLogger(LanguidProtocol.class);
private static final Logger log = LogManager.getLogger(LanguidProtocol.class);
private boolean ready = false;
private boolean initialized = false;
private String mbeanPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
import org.apache.traffic_control.traffic_router.secure.CertificateRegistry;
import org.apache.traffic_control.traffic_router.secure.HandshakeData;
import org.apache.traffic_control.traffic_router.secure.KeyManager;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.tomcat.jni.SSL;
import org.apache.tomcat.util.net.NioChannel;
import org.apache.tomcat.util.net.NioEndpoint;
Expand All @@ -34,7 +35,7 @@
import java.util.Set;

public class RouterNioEndpoint extends NioEndpoint {
private static final Logger LOGGER = Logger.getLogger(RouterNioEndpoint.class);
private static final Logger LOGGER = LogManager.getLogger(RouterNioEndpoint.class);
private String protocols;

// Grabs the aliases from our custom certificate registry, creates a sslHostConfig for them
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
package org.apache.traffic_control.traffic_router.secure;

import org.apache.traffic_control.traffic_router.shared.CertificateData;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bouncycastle.jcajce.provider.asymmetric.rsa.BCRSAPrivateCrtKey;

import java.math.BigInteger;
Expand All @@ -32,7 +33,7 @@

@SuppressWarnings({"PMD.CyclomaticComplexity"})
public class CertificateDataConverter {
private static final Logger log = Logger.getLogger(CertificateDataConverter.class);
private static final Logger log = LogManager.getLogger(CertificateDataConverter.class);

private PrivateKeyDecoder privateKeyDecoder = new PrivateKeyDecoder();
private CertificateDecoder certificateDecoder = new CertificateDecoder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
package org.apache.traffic_control.traffic_router.secure;

import org.apache.traffic_control.traffic_router.shared.CertificateData;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import javax.management.AttributeChangeNotification;
import javax.management.Notification;
Expand All @@ -25,7 +26,7 @@
import java.util.List;

public class CertificateDataListener implements NotificationListener {
private static final Logger log = Logger.getLogger(CertificateDataListener.class);
private static final Logger log = LogManager.getLogger(CertificateDataListener.class);

@SuppressWarnings("PMD.AvoidCatchingThrowable")
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

package org.apache.traffic_control.traffic_router.secure;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.ByteArrayInputStream;
import java.security.cert.CertificateFactory;
Expand All @@ -25,7 +26,7 @@
import java.util.List;

public class CertificateDecoder {
private static final Logger log = Logger.getLogger(CertificateDecoder.class);
private static final Logger log = LogManager.getLogger(CertificateDecoder.class);

private static final String CRT_HEADER = "-----BEGIN CERTIFICATE-----";
private static final String CRT_FOOTER = "-----END CERTIFICATE-----";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
import org.apache.traffic_control.traffic_router.protocol.RouterNioEndpoint;
import org.apache.traffic_control.traffic_router.shared.CertificateData;
import org.apache.traffic_control.traffic_router.utils.HttpsProperties;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.BasicConstraints;
import org.bouncycastle.asn1.x509.ExtendedKeyUsage;
Expand Down Expand Up @@ -55,7 +56,7 @@

public class CertificateRegistry {
public static final String DEFAULT_SSL_KEY = "default.invalid";
private static final Logger log = Logger.getLogger(CertificateRegistry.class);
private static final Logger log = LogManager.getLogger(CertificateRegistry.class);
private CertificateDataConverter certificateDataConverter = new CertificateDataConverter();
volatile private Map<String, HandshakeData> handshakeDataMap = new HashMap<>();
private RouterNioEndpoint sslEndpoint = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

package org.apache.traffic_control.traffic_router.secure;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import javax.net.ssl.ExtendedSSLSession;
import javax.net.ssl.SNIServerName;
Expand All @@ -36,7 +37,7 @@
// once the JVM loads the default classes.
public class KeyManager extends X509ExtendedKeyManager implements X509KeyManager {
private final CertificateRegistry certificateRegistry = CertificateRegistry.getInstance();
private static final Logger log = Logger.getLogger(KeyManager.class);
private static final Logger log = LogManager.getLogger(KeyManager.class);
// To date this method is not getting exercised while running the router
@Override
public String chooseClientAlias(final String[] strings, final Principal[] principals, final Socket socket) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleEvent;
import org.apache.catalina.LifecycleListener;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;


import javax.management.MBeanServer;
import javax.management.ObjectName;
import java.lang.management.ManagementFactory;

public class TomcatLifecycleListener implements LifecycleListener {
private static final Logger log = Logger.getLogger(LifecycleListener.class);
private static final Logger log = LogManager.getLogger(LifecycleListener.class);
private CertificateDataListener certificateDataListener = new CertificateDataListener();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@

package org.apache.traffic_control.traffic_router.utils;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;

public class HttpsProperties {
private static final Logger log = Logger.getLogger(HttpsProperties.class);
private static final Logger log = LogManager.getLogger(HttpsProperties.class);
private static final String HTTPS_PROPERTIES_FILE = "/opt/traffic_router/conf/https.properties";
private final Map<String, String> httpsPropertiesMap;

Expand Down
Loading