View Javadoc

1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2011, 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    /**
40     * Print the pattern string as a header in log files
41     *
42     * @param outputPatternAsHeader
43     * @since 1.0.3
44     */
45    public void setOutputPatternAsHeader(boolean outputPatternAsHeader) {
46      this.outputPatternAsHeader = outputPatternAsHeader;
47    }
48  
49  
50    public boolean isOutputPatternAsPresentationHeader() {
51      return outputPatternAsHeader;
52    }
53  
54    /**
55     * @deprecated replaced by {@link #setOutputPatternAsHeader(boolean)}
56     */
57    public void setOutputPatternAsPresentationHeader(boolean outputPatternAsHeader) {
58      addWarn("[outputPatternAsPresentationHeader] property is deprecated. Please use [outputPatternAsHeader] option instead.");
59      this.outputPatternAsHeader = outputPatternAsHeader;
60    }
61  
62    @Override
63    public void setLayout(Layout<E> layout) {
64      throw new UnsupportedOperationException("one cannot set the layout of "
65          + this.getClass().getName());
66    }
67  
68  }