View Javadoc
1   package ch.qos.logback.classic.issue.logback_1361;
2   import org.slf4j.Logger;
3   import org.slf4j.LoggerFactory;
4   
5   import ch.qos.logback.classic.ClassicTestConstants;
6   import ch.qos.logback.classic.LoggerContext;
7   import ch.qos.logback.classic.joran.JoranConfigurator;
8   
9   public class Main {
10      private static Logger logger = LoggerFactory.getLogger(Main.class);
11  
12      private static String ONE_KB_STRING;
13      
14      public static void main(String[] args) throws Exception {
15          LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
16          lc.reset();
17          lc.putProperty("output_dir", ClassicTestConstants.OUTPUT_DIR_PREFIX+"logback_issue_1361/");
18          
19          JoranConfigurator configurator = new JoranConfigurator();
20          configurator.setContext(lc);
21          configurator.doConfigure(ClassicTestConstants.INPUT_PREFIX+ "issue/logback_1361.xml");
22  
23          log1MegaByteInOneSecond();
24      }
25      
26      static {
27          StringBuilder sb = new StringBuilder();
28          for (int j = 0; j < 100; j++) {
29              String message = "1234567890";
30              sb.append(message);
31          }
32          ONE_KB_STRING = sb.toString();
33      }
34  
35  
36      private static void log1MegaByteInOneSecond() throws Exception {
37          for (int i = 0; i < 1000; i++) {
38              logger.warn(i + " - " + ONE_KB_STRING);
39              Thread.sleep(1);
40          }
41      }
42  
43  
44  }