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.log4j; 018 019 import org.apache.log4j.spi.LoggingEvent; 020 021 /** 022 * 023 */ 024 public abstract class Layout { 025 026 // Note that the line.separator property can be looked up even by 027 // applets. 028 public final static String LINE_SEP = System.getProperty("line.separator"); 029 public final static int LINE_SEP_LEN = LINE_SEP.length(); 030 031 032 /** 033 * Implement this method to create your own layout format. 034 */ 035 public abstract String format(LoggingEvent event); 036 037 /** 038 * Returns the content type output by this layout. The base class 039 * returns "text/plain". 040 */ 041 public String getContentType() { 042 return "text/plain"; 043 } 044 045 /** 046 * Returns the header for the layout format. The base class returns 047 * <code>null</code>. 048 */ 049 public String getHeader() { 050 return null; 051 } 052 053 /** 054 * Returns the footer for the layout format. The base class returns 055 * <code>null</code>. 056 */ 057 public String getFooter() { 058 return null; 059 } 060 061 062 /** 063 * If the layout handles the throwable object contained within 064 * {@link LoggingEvent}, then the layout should return 065 * {@code false}. Otherwise, if the layout ignores throwable 066 * object, then the layout should return {@code true}. 067 * If ignoresThrowable is true, the appender is responsible for 068 * rendering the throwable. 069 * <p/> 070 * <p>The {@link SimpleLayout}, {@link TTCCLayout}, {@link 071 * PatternLayout} all return {@code true}. The {@link 072 * org.apache.log4j.xml.XMLLayout} returns {@code false}. 073 * 074 * @since 0.8.4 075 */ 076 public abstract boolean ignoresThrowable(); 077 } 078