Apache log4j提供布局对象,以根据各种布局格式化日志数据。
布局类层次结构中的顶级类是抽象类org.apache.log4j.Layout。
org.apache.log4j.Layout是log4j API中所有其他Layout类的基类。
它有以下子类。
- DateLayout
- HTMLLayout
- PatternLayout。
- SimpleLayout
- XMLLayout
布局类的方法
下表列出了Layout类中的类。
方法描述public abstract boolean ignoresThrowable()如果忽略Throwable对象。public abstract String format(LoggingEvent event)实现此方法以进行格式化布局。public String getContentType()返回布局对象使用的内容类型。public String getFooter()记录消息的页脚信息。public String getHeader()日志消息的头信息。