forked from apache/kafka
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KAFKA-18396: Migrate log4j1 configuration to log4j2 in KafkaDockerWra…
…pper (apache#18394) After log4j migration, we need to update the logging configuration in KafkaDockerWrapper from log4j1 to log4j2. Reviewers: Manikumar Reddy <[email protected]>
- Loading branch information
1 parent
9fc7500
commit f5dd661
Showing
8 changed files
with
578 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
221 changes: 221 additions & 0 deletions
221
core/src/main/java/kafka/docker/Log4jConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package kafka.docker; | ||
|
||
import com.fasterxml.jackson.annotation.JsonAnyGetter; | ||
import com.fasterxml.jackson.annotation.JsonAnySetter; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
|
||
import java.util.Collections; | ||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class Log4jConfiguration { | ||
private Configuration configuration; | ||
|
||
@JsonProperty("Configuration") | ||
public Configuration getConfiguration() { | ||
return configuration; | ||
} | ||
|
||
public void setConfiguration(Configuration configuration) { | ||
this.configuration = configuration; | ||
} | ||
} | ||
|
||
@JsonPropertyOrder({ "Properties", "Appenders", "Loggers" }) | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
class Configuration { | ||
private Properties properties; | ||
private Appenders appenders; | ||
private Loggers loggers; | ||
private final Map<String, Object> additionalProperties = new LinkedHashMap<>(); | ||
|
||
@JsonProperty("Properties") | ||
public Properties getProperties() { | ||
return properties; | ||
} | ||
|
||
public void setProperties(Properties properties) { | ||
this.properties = properties; | ||
} | ||
|
||
@JsonProperty("Appenders") | ||
public Appenders getAppenders() { | ||
return appenders; | ||
} | ||
|
||
public void setAppenders(Appenders appenders) { | ||
this.appenders = appenders; | ||
} | ||
|
||
@JsonProperty("Loggers") | ||
public Loggers getLoggers() { | ||
return loggers; | ||
} | ||
|
||
public void setLoggers(Loggers loggers) { | ||
this.loggers = loggers; | ||
} | ||
|
||
@JsonAnyGetter | ||
public Map<String, Object> getAdditionalProperties() { | ||
return additionalProperties; | ||
} | ||
|
||
@JsonAnySetter | ||
public void setAdditionalProperties(String key, Object value) { | ||
additionalProperties.put(key, value); | ||
} | ||
} | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
class Properties { | ||
private final Map<String, Object> properties = new LinkedHashMap<>(); | ||
|
||
@JsonAnyGetter | ||
public Map<String, Object> getProperties() { | ||
return properties; | ||
} | ||
|
||
@JsonAnySetter | ||
public void setProperties(String key, Object value) { | ||
properties.put(key, value); | ||
} | ||
} | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
class Appenders { | ||
private final Map<String, Object> properties = new LinkedHashMap<>(); | ||
|
||
@JsonAnyGetter | ||
public Map<String, Object> getProperties() { | ||
return properties; | ||
} | ||
|
||
@JsonAnySetter | ||
public void setProperties(String key, Object value) { | ||
properties.put(key, value); | ||
} | ||
} | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
class Loggers { | ||
private Root root; | ||
private List<Logger> logger = Collections.emptyList(); | ||
|
||
@JsonProperty("Root") | ||
public Root getRoot() { | ||
return root; | ||
} | ||
|
||
public void setRoot(Root root) { | ||
this.root = root; | ||
} | ||
|
||
@JsonProperty("Logger") | ||
public List<Logger> getLogger() { | ||
return logger; | ||
} | ||
|
||
public void setLogger(List<Logger> logger) { | ||
this.logger = logger; | ||
} | ||
} | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
class Root { | ||
private String level; | ||
private final Map<String, Object> otherProperties = new LinkedHashMap<>(); | ||
|
||
public String getLevel() { | ||
return level; | ||
} | ||
|
||
public void setLevel(String level) { | ||
this.level = level; | ||
} | ||
|
||
@JsonAnyGetter | ||
public Map<String, Object> getOtherProperties() { | ||
return otherProperties; | ||
} | ||
|
||
@JsonAnySetter | ||
public void setOtherProperties(String key, Object value) { | ||
otherProperties.put(key, value); | ||
} | ||
} | ||
|
||
@JsonPropertyOrder({ "name", "level" }) | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
class Logger { | ||
private String name; | ||
private String level; | ||
private final Map<String, Object> otherProperties = new LinkedHashMap<>(); | ||
|
||
@JsonProperty("name") | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
@JsonProperty("level") | ||
public String getLevel() { | ||
return level; | ||
} | ||
|
||
public void setLevel(String level) { | ||
this.level = level; | ||
} | ||
|
||
@JsonAnyGetter | ||
public Map<String, Object> getOtherProperties() { | ||
return otherProperties; | ||
} | ||
|
||
@JsonAnySetter | ||
public void setOtherProperties(String key, Object value) { | ||
otherProperties.put(key, value); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
Logger logger = (Logger) o; | ||
return Objects.equals(name, logger.name) && | ||
Objects.equals(level, logger.level) && | ||
Objects.equals(otherProperties, logger.otherProperties); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = Objects.hashCode(name); | ||
result = 31 * result + Objects.hashCode(level); | ||
result = 31 * result + Objects.hashCode(otherProperties); | ||
return result; | ||
} | ||
} |
Oops, something went wrong.