Skip to content

Commit

Permalink
RANGER-3032: Load log4j changes dynamically
Browse files Browse the repository at this point in the history
Signed-off-by: pradeep <pradeep@apache.org>
  • Loading branch information
rujia1019 authored and pradeepagrawal8184 committed Nov 21, 2020
1 parent 6fc3878 commit 7cfc706
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.apache.catalina.valves.ErrorReportValve;
import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.security.SecureClientLogin;
import org.apache.log4j.PropertyConfigurator;
import org.apache.ranger.credentialapi.CredentialReader;

import javax.net.ssl.KeyManager;
Expand Down Expand Up @@ -88,6 +89,11 @@ public EmbeddedServer(String[] args) {
if (args.length > 0) {
configFile = args[0];
}

// load log configuration file dynamically if log4j.properties changed
String logPropFile = StringUtils.splitByWholeSeparator(System.getProperty("log4j.configuration"), ":")[1];
PropertyConfigurator.configureAndWatch(logPropFile, 10000L);

EmbeddedServerUtil.loadRangerConfigProperties(configFile);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.hadoop.security.SecureClientLogin;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.apache.ranger.tagsync.model.TagSink;
import org.apache.ranger.tagsync.model.TagSource;

Expand All @@ -53,6 +54,11 @@ public class TagSynchronizer {
private volatile boolean isShutdownInProgress = false;

public static void main(String[] args) {

// load log configuration file dynamically if log4j.properties changed
String logPropFile = StringUtils.splitByWholeSeparator(System.getProperty("log4j.configuration"), ":")[1];
PropertyConfigurator.configureAndWatch(logPropFile, 10000L);

TagSynchronizer tagSynchronizer = new TagSynchronizer();

TagSyncConfig config = TagSyncConfig.getInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.apache.ranger.credentialapi.CredentialReader;
import org.apache.ranger.plugin.util.XMLUtils;
import org.apache.ranger.unixusersync.config.UserGroupSyncConfig;
Expand Down Expand Up @@ -89,6 +91,11 @@ public class UnixAuthenticationService {
private static final String[] UGSYNC_CONFIG_XML_FILES = { "ranger-ugsync-default.xml", "ranger-ugsync-site.xml" };

public static void main(String[] args) {

// load log configuration file dynamically if log4j.properties changed
String logPropFile = StringUtils.splitByWholeSeparator(System.getProperty("log4j.configuration"), ":")[1];
PropertyConfigurator.configureAndWatch(logPropFile, 10000L);

if (args.length > 0) {
for (String s : args) {
if ("-enableUnixAuth".equalsIgnoreCase(s)) {
Expand Down

0 comments on commit 7cfc706

Please sign in to comment.