Revert "Respect enableReverseDnsLookup option in ErrorLogJsonLayout"
Reason for revert: enableReverseDnsLookup is unrelated for local
hostname DNS lookup for rendering of error log. Beside that this option
will be removed in follow up change.
This reverts commit b3cbbc9ad6
.
Change-Id: I8f74ca039246753f775b7bfc96596e3f5159af01
This commit is contained in:
parent
b2e6721227
commit
236bc4052c
|
@ -95,14 +95,9 @@ public class ErrorLogFile {
|
|||
}
|
||||
|
||||
if (json) {
|
||||
Boolean enableReverseDnsLookup =
|
||||
config.getBoolean("gerrit", null, "enableReverseDnsLookup", false);
|
||||
root.addAppender(
|
||||
SystemLog.createAppender(
|
||||
logdir,
|
||||
LOG_NAME + JSON_SUFFIX,
|
||||
new ErrorLogJsonLayout(enableReverseDnsLookup),
|
||||
rotate));
|
||||
logdir, LOG_NAME + JSON_SUFFIX, new ErrorLogJsonLayout(), rotate));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,12 +26,6 @@ import org.apache.log4j.spi.ThrowableInformation;
|
|||
|
||||
/** Layout for formatting error log events in the JSON format. */
|
||||
public class ErrorLogJsonLayout extends JsonLayout {
|
||||
private final Boolean enableReverseDnsLookup;
|
||||
|
||||
public ErrorLogJsonLayout(Boolean enableDnsReverseLookup) {
|
||||
super();
|
||||
this.enableReverseDnsLookup = enableDnsReverseLookup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonLogEntry toJsonLogEntry(LoggingEvent event) {
|
||||
|
@ -86,7 +80,7 @@ public class ErrorLogJsonLayout extends JsonLayout {
|
|||
|
||||
public ErrorJsonLogEntry(LoggingEvent event) {
|
||||
this.timestamp = timestampFormatter.format(event.getTimeStamp());
|
||||
this.sourceHost = getSourceHost(enableReverseDnsLookup);
|
||||
this.sourceHost = getSourceHost();
|
||||
this.message = event.getRenderedMessage();
|
||||
this.file = event.getLocationInformation().getFileName();
|
||||
this.lineNumber = event.getLocationInformation().getLineNumber();
|
||||
|
@ -102,14 +96,9 @@ public class ErrorLogJsonLayout extends JsonLayout {
|
|||
}
|
||||
}
|
||||
|
||||
private String getSourceHost(Boolean enableReverseDnsLookup) {
|
||||
InetAddress in;
|
||||
private String getSourceHost() {
|
||||
try {
|
||||
in = InetAddress.getLocalHost();
|
||||
if (Boolean.TRUE.equals(enableReverseDnsLookup)) {
|
||||
return in.getCanonicalHostName();
|
||||
}
|
||||
return in.getHostAddress();
|
||||
return InetAddress.getLocalHost().getHostName();
|
||||
} catch (UnknownHostException e) {
|
||||
return "unknown-host";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue