001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache license, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the license for the specific language governing permissions and 015 * limitations under the license. 016 */ 017 package org.apache.logging.log4j.core.layout; 018 019 import org.apache.logging.log4j.Logger; 020 import org.apache.logging.log4j.core.Layout; 021 import org.apache.logging.log4j.status.StatusLogger; 022 023 import java.io.Serializable; 024 025 /** 026 * Abstract base class for Layouts. 027 * @param <T> The Class that the Layout will format the LogEvent into. 028 */ 029 public abstract class AbstractLayout<T extends Serializable> implements Layout<T> { 030 /** 031 * Allow subclasses access to the status logger without creating another instance. 032 */ 033 protected static final Logger LOGGER = StatusLogger.getLogger(); 034 /** 035 * The header to include when the stream is opened. May be null. 036 */ 037 protected byte[] header; 038 /** 039 * The footer to add when the stream is closed. May be null. 040 */ 041 protected byte[] footer; 042 043 /** 044 * Returns the header, if one is available. 045 * @return A byte array containing the header. 046 */ 047 public byte[] getHeader() { 048 return header; 049 } 050 051 /** 052 * Set the header. 053 * @param header The header. 054 */ 055 public void setHeader(final byte[] header) { 056 this.header = header; 057 } 058 059 /** 060 * Returns the footer, if one is available. 061 * @return A byte array containing the footer. 062 */ 063 public byte[] getFooter() { 064 return footer; 065 } 066 067 /** 068 * Set the footer. 069 * @param footer The footer. 070 */ 071 public void setFooter(final byte[] footer) { 072 this.footer = footer; 073 } 074 }