logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattsic...@apache.org
Subject svn commit: r1582193 - /logging/log4j/log4j2/trunk/log4j-core/src/test/resources/README.md
Date Thu, 27 Mar 2014 05:34:58 GMT
Author: mattsicker
Date: Thu Mar 27 05:34:58 2014
New Revision: 1582193

URL: http://svn.apache.org/r1582193
Log:
Update documentation.

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/test/resources/README.md

Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/resources/README.md
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/resources/README.md?rev=1582193&r1=1582192&r2=1582193&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/resources/README.md (original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/resources/README.md Thu Mar 27 05:34:58
2014
@@ -34,14 +34,14 @@ suppose your test class uses the file na
 in your test class:
 
     @Rule
-    public InitialLoggerContext context = new InitialLoggerContext("MyTestConfig.xml");
+    public InitialLoggerContext init = new InitialLoggerContext("MyTestConfig.xml");
 
     @Test
     public void testSomeAwesomeFeature() {
-        final LoggerContext ctx = context.getContext();
-        final Logger logger = ctx.getLogger("org.apache.logging.log4j.my.awesome.test.logger");
-        final Configuration cfg = ctx.getConfiguration();
-        final ListAppender app = (ListAppender) cfg.getAppenders().get("List");
+        final LoggerContext ctx = init.getContext();
+        final Logger logger = init.getLogger("org.apache.logging.log4j.my.awesome.test.logger");
+        final Configuration cfg = init.getConfiguration();
+        final ListAppender app = (ListAppender) init.getAppender("List");
         logger.warn("Test message");
         final List<LogEvent> events = app.getEvents();
         // etc.
@@ -52,5 +52,15 @@ retrieve via the `getContext()` method s
 the field `static`), the `LoggerContext` is automatically stopped. No longer do you need
to set any system properties,
 reset the `StatusLogger` configuration, and all that other fun boilerplate code.
 
+Cleaning Up Test Log Files
+--------------------------
+
+The `CleanFiles` rule is also available to automatically delete a list of files before and
after every test.
+
+    @Rule
+    public CleanFiles files = new CleanFiles("target/file1.log", "target/file2.log", "more
files");
+
+You can specify either a list of strings or a list of `File`s.
+
 If you have any questions about writing unit tests, feel free to send an email to the dev
mailing list, or check out
 the JUnit documentation over at junit.org.
\ No newline at end of file



Mime
View raw message