You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2022/01/09 15:50:32 UTC
[logging-log4j2] branch release-2.x updated: Javadoc. Format tweaks. Use NIO. Drop single use local.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/release-2.x by this push:
new 82d291f Javadoc. Format tweaks. Use NIO. Drop single use local.
82d291f is described below
commit 82d291fa6ecbe2b5da4b111e7078d9a2807fa493
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jan 9 10:50:30 2022 -0500
Javadoc. Format tweaks. Use NIO. Drop single use local.
---
.../org/apache/logging/log4j/simple/SimpleLoggerContext.java | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java b/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
index fe460c6..8561318 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
@@ -19,6 +19,7 @@ package org.apache.logging.log4j.simple;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
+import java.nio.file.Files;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.message.MessageFactory;
@@ -29,7 +30,7 @@ import org.apache.logging.log4j.spi.LoggerRegistry;
import org.apache.logging.log4j.util.PropertiesUtil;
/**
- *
+ * A simple {@link LoggerContext} implementation.
*/
public class SimpleLoggerContext implements LoggerContext {
@@ -53,10 +54,13 @@ public class SimpleLoggerContext implements LoggerContext {
* lost in a flood of messages without knowing who sends them.
*/
private final boolean showShortName;
+
/** Include the current time in the log message */
private final boolean showDateTime;
+
/** Include the ThreadContextMap in the log message */
private final boolean showContextMap;
+
/** The date and time format to use in the log message */
private final String dateTimeFormat;
@@ -66,6 +70,9 @@ public class SimpleLoggerContext implements LoggerContext {
private final LoggerRegistry<ExtendedLogger> loggerRegistry = new LoggerRegistry<>();
+ /**
+ * Constructs a new initialized instance.
+ */
public SimpleLoggerContext() {
props = new PropertiesUtil("log4j2.simplelog.properties");
@@ -87,8 +94,7 @@ public class SimpleLoggerContext implements LoggerContext {
ps = System.out;
} else {
try {
- final FileOutputStream os = new FileOutputStream(fileName);
- ps = new PrintStream(os);
+ ps = new PrintStream(new FileOutputStream(fileName));
} catch (final FileNotFoundException fnfe) {
ps = System.err;
}