1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache license, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the license for the specific language governing permissions and 15 * limitations under the license. 16 */ 17 package org.apache.logging.log4j.core.layout; 18 19 import org.apache.logging.log4j.Logger; 20 import org.apache.logging.log4j.core.Layout; 21 import org.apache.logging.log4j.status.StatusLogger; 22 23 import java.io.Serializable; 24 25 /** 26 * Abstract base class for Layouts. 27 * @param <T> The Class that the Layout will format the LogEvent into. 28 */ 29 public abstract class AbstractLayout<T extends Serializable> implements Layout<T> { 30 /** 31 * Allow subclasses access to the status logger without creating another instance. 32 */ 33 protected static final Logger LOGGER = StatusLogger.getLogger(); 34 /** 35 * The header to include when the stream is opened. May be null. 36 */ 37 protected byte[] header; 38 /** 39 * The footer to add when the stream is closed. May be null. 40 */ 41 protected byte[] footer; 42 43 /** 44 * Returns the header, if one is available. 45 * @return A byte array containing the header. 46 */ 47 public byte[] getHeader() { 48 return header; 49 } 50 51 /** 52 * Set the header. 53 * @param header The header. 54 */ 55 public void setHeader(byte[] header) { 56 this.header = header; 57 } 58 59 /** 60 * Returns the footer, if one is available. 61 * @return A byte array containing the footer. 62 */ 63 public byte[] getFooter() { 64 return footer; 65 } 66 67 /** 68 * Set the footer. 69 * @param footer The footer. 70 */ 71 public void setFooter(byte[] footer) { 72 this.footer = footer; 73 } 74 }