1   /*
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2026, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v2.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  
15  package ch.qos.logback.classic.issue.logback_1361;
16  
17  import org.slf4j.Logger;
18  import org.slf4j.LoggerFactory;
19  
20  import ch.qos.logback.classic.ClassicTestConstants;
21  import ch.qos.logback.classic.LoggerContext;
22  import ch.qos.logback.classic.joran.JoranConfigurator;
23  
24  public class Main {
25      private static Logger logger = LoggerFactory.getLogger(Main.class);
26  
27      private static String ONE_KB_STRING;
28  
29      public static void main(String[] args) throws Exception {
30          LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
31          lc.reset();
32          lc.putProperty("output_dir", ClassicTestConstants.OUTPUT_DIR_PREFIX + "logback_issue_1361/");
33  
34          JoranConfigurator configurator = new JoranConfigurator();
35          configurator.setContext(lc);
36          configurator.doConfigure(ClassicTestConstants.INPUT_PREFIX + "issue/logback_1361.xml");
37  
38          log1MegaByteInOneSecond();
39      }
40  
41      static {
42          StringBuilder sb = new StringBuilder();
43          for (int j = 0; j < 100; j++) {
44              String message = "1234567890";
45              sb.append(message);
46          }
47          ONE_KB_STRING = sb.toString();
48      }
49  
50      private static void log1MegaByteInOneSecond() throws Exception {
51          for (int i = 0; i < 1000; i++) {
52              logger.warn(i + " - " + ONE_KB_STRING);
53              Thread.sleep(1);
54          }
55      }
56  
57  }