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 */ 017package org.apache.log4j.builders.layout; 018 019import org.apache.log4j.Layout; 020import org.apache.log4j.bridge.LayoutWrapper; 021import org.apache.log4j.config.PropertiesConfiguration; 022import org.apache.log4j.xml.XmlConfiguration; 023import org.apache.logging.log4j.Logger; 024import org.apache.logging.log4j.core.config.plugins.Plugin; 025import org.apache.logging.log4j.core.layout.PatternLayout; 026import org.apache.logging.log4j.status.StatusLogger; 027import org.w3c.dom.Element; 028 029import static org.apache.log4j.builders.BuilderManager.CATEGORY; 030 031/** 032 * Build a Pattern Layout 033 */ 034@Plugin(name = "org.apache.log4j.SimpleLayout", category = CATEGORY) 035public class SimpleLayoutBuilder implements LayoutBuilder { 036 037 private static final Logger LOGGER = StatusLogger.getLogger(); 038 039 @Override 040 public Layout parseLayout(Element layoutElement, XmlConfiguration config) { 041 return new LayoutWrapper(PatternLayout.newBuilder() 042 .withPattern("%level - %m%n") 043 .withConfiguration(config) 044 .build()); 045 } 046 047 @Override 048 public Layout parseLayout(PropertiesConfiguration config) { 049 return new LayoutWrapper(PatternLayout.newBuilder() 050 .withPattern("%level - %m%n") 051 .withConfiguration(config) 052 .build()); 053 } 054}