Skip to content

Commit 1abae3e

Browse files
fix toString() method in configuration implementations (apache#3599)
1 parent 4a7ddf1 commit 1abae3e

File tree

4 files changed

+7
-31
lines changed

4 files changed

+7
-31
lines changed

log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.io.InputStream;
2323
import java.lang.ref.WeakReference;
2424
import java.net.URI;
25+
import java.time.Instant;
2526
import java.util.ArrayList;
2627
import java.util.Arrays;
2728
import java.util.Collection;
@@ -1187,6 +1188,12 @@ private Object createPluginObject(final PluginType<?> type, final Node node, fin
11871188
return map;
11881189
}
11891190

1191+
@Override
1192+
public String toString() {
1193+
return getClass().getSimpleName() + "[location=" + getConfigurationSource() + ", lastModified="
1194+
+ Instant.ofEpochMilli(getConfigurationSource().getLastModified()) + "]";
1195+
}
1196+
11901197
private static Collection<?> createPluginCollection(final Node node) {
11911198
final List<Node> children = node.getChildren();
11921199
final Collection<Object> list = new ArrayList<>(children.size());

log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/CompositeConfiguration.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,4 @@ private void printNodes(final String indent, final Node node, final StringBuilde
183183
printNodes(indent + " ", child, sb);
184184
}
185185
}
186-
187-
@Override
188-
public String toString() {
189-
return getClass().getName() + "@" + Integer.toHexString(hashCode()) + " [configurations=" + configurations
190-
+ ", mergeStrategy=" + mergeStrategy + ", rootNode=" + rootNode + ", listeners=" + listeners
191-
+ ", pluginPackages=" + pluginPackages + ", pluginManager=" + pluginManager + ", isShutdownHookEnabled="
192-
+ isShutdownHookEnabled + ", shutdownTimeoutMillis=" + shutdownTimeoutMillis + ", scriptManager="
193-
+ scriptManager + "]";
194-
}
195186
}

log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,6 @@ private void processAttributes(final Node parent, final JsonNode node) {
236236
}
237237
}
238238

239-
@Override
240-
public String toString() {
241-
return getClass().getSimpleName() + "[location=" + getConfigurationSource() + "]";
242-
}
243-
244239
/**
245240
* The error that occurred.
246241
*/
@@ -261,10 +256,5 @@ public Status(final String name, final JsonNode node, final ErrorType errorType)
261256
this.node = node;
262257
this.errorType = errorType;
263258
}
264-
265-
@Override
266-
public String toString() {
267-
return "Status [name=" + name + ", errorType=" + errorType + ", node=" + node + "]";
268-
}
269259
}
270260
}

log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.io.ByteArrayInputStream;
2121
import java.io.IOException;
2222
import java.io.InputStream;
23-
import java.time.Instant;
2423
import java.util.ArrayList;
2524
import java.util.Arrays;
2625
import java.util.List;
@@ -336,12 +335,6 @@ private Map<String, String> processAttributes(final Node node, final Element ele
336335
return attributes;
337336
}
338337

339-
@Override
340-
public String toString() {
341-
return getClass().getSimpleName() + "[location=" + getConfigurationSource() + ", lastModified="
342-
+ Instant.ofEpochMilli(getConfigurationSource().getLastModified()) + "]";
343-
}
344-
345338
/**
346339
* The error that occurred.
347340
*/
@@ -362,10 +355,5 @@ public Status(final String name, final Element element, final ErrorType errorTyp
362355
this.element = element;
363356
this.errorType = errorType;
364357
}
365-
366-
@Override
367-
public String toString() {
368-
return "Status [name=" + name + ", element=" + element + ", errorType=" + errorType + "]";
369-
}
370358
}
371359
}

0 commit comments

Comments
 (0)