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 java.io.Serializable; 20 21 import org.apache.logging.log4j.Logger; 22 import org.apache.logging.log4j.core.Layout; 23 import org.apache.logging.log4j.status.StatusLogger; 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 @Override 48 public byte[] getHeader() { 49 return header; 50 } 51 52 /** 53 * Set the header. 54 * @param header The header. 55 */ 56 public void setHeader(final byte[] header) { 57 this.header = header; 58 } 59 60 /** 61 * Returns the footer, if one is available. 62 * @return A byte array containing the footer. 63 */ 64 @Override 65 public byte[] getFooter() { 66 return footer; 67 } 68 69 /** 70 * Set the footer. 71 * @param footer The footer. 72 */ 73 public void setFooter(final byte[] footer) { 74 this.footer = footer; 75 } 76 }