1   /**
2    * Logback: the generic, reliable, fast and flexible logging framework.
3    * 
4    * Copyright (C) 2000-2008, QOS.ch
5    * 
6    * This library is free software, you can redistribute it and/or modify it under
7    * the terms of the GNU Lesser General Public License as published by the Free
8    * Software Foundation.
9    */
10  package ch.qos.logback.classic.net.testObjectBuilders;
11  
12  import ch.qos.logback.classic.Level;
13  import ch.qos.logback.classic.Logger;
14  import ch.qos.logback.classic.LoggerContext;
15  import ch.qos.logback.classic.spi.LoggingEvent;
16  
17  public class LoggingEventWithParametersBuilder implements Builder {
18  
19    final String MSG = "aaaaabbbbbcccc {} cdddddaaaaabbbbbcccccdddddaaaa {}";
20  
21    private Logger logger = new LoggerContext()
22        .getLogger(LoggerContext.ROOT_NAME);
23  
24    public Object build(int i) {
25  
26      LoggingEvent le = new LoggingEvent();
27      le.setTimeStamp(System.currentTimeMillis());
28  
29      Object[] aa = new Object[] { i, "HELLO WORLD [========== ]" + i };
30  
31      le.setArgumentArray(aa);
32      String msg = MSG + i;
33      le.setMessage(msg);
34  
35      // compute formatted message
36      // this forces le.formmatedMessage to be set (this is the whole point of the
37      // exercise)
38      le.getFormattedMessage();
39      le.setLevel(Level.DEBUG);
40      le.setLoggerRemoteView(logger.getLoggerRemoteView());
41      le.setThreadName("threadName");
42  
43      return le;
44    }
45  }