View Javadoc
1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2015, 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 v1.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  package ch.qos.logback.core.pattern;
15  
16  import ch.qos.logback.core.Layout;
17  import ch.qos.logback.core.encoder.LayoutWrappingEncoder;
18  
19  public class PatternLayoutEncoderBase<E> extends LayoutWrappingEncoder<E> {
20  
21      String pattern;
22  
23      // due to popular demand outputPatternAsHeader is set to false by default
24      protected boolean outputPatternAsHeader = false;
25  
26      public String getPattern() {
27          return pattern;
28      }
29  
30      public void setPattern(String pattern) {
31          this.pattern = pattern;
32      }
33  
34      public boolean isOutputPatternAsHeader() {
35          return outputPatternAsHeader;
36      }
37  
38      /**
39       * Print the pattern string as a header in log files
40       *
41       * @param outputPatternAsHeader
42       * @since 1.0.3
43       */
44      public void setOutputPatternAsHeader(boolean outputPatternAsHeader) {
45          this.outputPatternAsHeader = outputPatternAsHeader;
46      }
47  
48      public boolean isOutputPatternAsPresentationHeader() {
49          return outputPatternAsHeader;
50      }
51  
52      /**
53       * @deprecated replaced by {@link #setOutputPatternAsHeader(boolean)}
54       */
55      public void setOutputPatternAsPresentationHeader(boolean outputPatternAsHeader) {
56          addWarn("[outputPatternAsPresentationHeader] property is deprecated. Please use [outputPatternAsHeader] option instead.");
57          this.outputPatternAsHeader = outputPatternAsHeader;
58      }
59  
60      @Override
61      public void setLayout(Layout<E> layout) {
62          throw new UnsupportedOperationException("one cannot set the layout of " + this.getClass().getName());
63      }
64  
65  }