This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git


The following commit(s) were added to refs/heads/master by this push:
     new 986fdc1  Javadoc. Format tweaks. Use NIO. Drop single use local.
986fdc1 is described below

commit 986fdc184bd0cd1784a26331f8d61a051924ced4
Author: Gary Gregory <[email protected]>
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;
             }

Reply via email to