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.nio.charset.Charset; 20 import java.nio.charset.StandardCharsets; 21 import java.util.HashMap; 22 import java.util.Map; 23 24 import org.apache.logging.log4j.core.Layout; 25 import org.apache.logging.log4j.core.config.Node; 26 import org.apache.logging.log4j.core.config.plugins.Plugin; 27 import org.apache.logging.log4j.core.config.plugins.PluginAttribute; 28 import org.apache.logging.log4j.core.config.plugins.PluginFactory; 29 import org.apache.logging.log4j.core.jackson.XmlConstants; 30 31 // Lines too long... 32 //CHECKSTYLE:OFF 33 /** 34 * Appends a series of {@code event} elements as defined in the <a href="log4j.dtd">log4j.dtd</a>. 35 * 36 * <h3>Complete well-formed XML vs. fragment XML</h3> 37 * <p> 38 * If you configure {@code complete="true"}, the appender outputs a well-formed XML document where the default namespace is the log4j 39 * namespace {@value XmlConstants#XML_NAMESPACE}. By default, with {@code complete="false"}, you should include the output as an 40 * <em>external entity</em> in a separate file to form a well-formed XML document. 41 * </p> 42 * <p> 43 * A well-formed XML document follows this pattern: 44 * </p> 45 * <pre> 46 <Event xmlns="http://logging.apache.org/log4j/2.0/events" timeMillis="1" thread="MyThreadName" level="DEBUG" loggerName="a.B" loggerFQCN="f.q.c.n" endOfBatch="false"> 47 <Marker name="Marker1"> 48 <Parents> 49 <Parents name="ParentMarker1"> 50 <Parents> 51 <Parents name="GrandMotherMarker"/> 52 <Parents name="GrandFatherMarker"/> 53 </Parents> 54 </Parents> 55 <Parents name="GrandFatherMarker"/> 56 </Parents> 57 </Marker> 58 <Message>Msg</Message> 59 <ContextMap> 60 <item key="MDC.B" value="B_Value"/> 61 <item key="MDC.A" value="A_Value"/> 62 </ContextMap> 63 <ContextStack> 64 <ContextStack>stack_msg1</ContextStack> 65 <ContextStack>stack_msg2</ContextStack> 66 </ContextStack> 67 <Source class="org.apache.logging.log4j.core.layout.LogEventFixtures" method="createLogEvent" file="LogEventFixtures.java" line="54"/> 68 <Thrown commonElementCount="0" localizedMessage="testIOEx" message="testIOEx" name="java.io.IOException"> 69 <Cause commonElementCount="27" localizedMessage="testNPEx" message="testNPEx" name="java.lang.NullPointerException"> 70 <ExtendedStackTrace> 71 <ExtendedStackTrace class="org.apache.logging.log4j.core.layout.LogEventFixtures" method="createLogEvent" file="LogEventFixtures.java" line="53" exact="false" location="test-classes/" version="?"/> 72 </ExtendedStackTrace> 73 </Cause> 74 <ExtendedStackTrace> 75 <ExtendedStackTrace class="org.apache.logging.log4j.core.layout.LogEventFixtures" method="createLogEvent" file="LogEventFixtures.java" line="56" exact="true" location="test-classes/" version="?"/> 76 <ExtendedStackTrace class="org.apache.logging.log4j.core.layout.XmlLayoutTest" method="testAllFeatures" file="XmlLayoutTest.java" line="122" exact="true" location="test-classes/" version="?"/> 77 <ExtendedStackTrace class="org.apache.logging.log4j.core.layout.XmlLayoutTest" method="testLocationOnCompactOnMdcOn" file="XmlLayoutTest.java" line="270" exact="true" location="test-classes/" version="?"/> 78 <ExtendedStackTrace class="sun.reflect.NativeMethodAccessorImpl" method="invoke" line="-1" exact="false" location="?" version="1.7.0_55"/> 79 <ExtendedStackTrace class="sun.reflect.NativeMethodAccessorImpl" method="invoke" line="-1" exact="false" location="?" version="1.7.0_55"/> 80 <ExtendedStackTrace class="sun.reflect.DelegatingMethodAccessorImpl" method="invoke" line="-1" exact="false" location="?" version="1.7.0_55"/> 81 <ExtendedStackTrace class="java.lang.reflect.Method" method="invoke" line="-1" exact="false" location="?" version="1.7.0_55"/> 82 <ExtendedStackTrace class="org.junit.runners.model.FrameworkMethod$1" method="runReflectiveCall" file="FrameworkMethod.java" line="47" exact="true" location="junit-4.11.jar" version="?"/> 83 <ExtendedStackTrace class="org.junit.internal.runners.model.ReflectiveCallable" method="run" file="ReflectiveCallable.java" line="12" exact="true" location="junit-4.11.jar" version="?"/> 84 <ExtendedStackTrace class="org.junit.runners.model.FrameworkMethod" method="invokeExplosively" file="FrameworkMethod.java" line="44" exact="true" location="junit-4.11.jar" version="?"/> 85 <ExtendedStackTrace class="org.junit.internal.runners.statements.InvokeMethod" method="evaluate" file="InvokeMethod.java" line="17" exact="true" location="junit-4.11.jar" version="?"/> 86 <ExtendedStackTrace class="org.junit.runners.ParentRunner" method="runLeaf" file="ParentRunner.java" line="271" exact="true" location="junit-4.11.jar" version="?"/> 87 <ExtendedStackTrace class="org.junit.runners.BlockJUnit4ClassRunner" method="runChild" file="BlockJUnit4ClassRunner.java" line="70" exact="true" location="junit-4.11.jar" version="?"/> 88 <ExtendedStackTrace class="org.junit.runners.BlockJUnit4ClassRunner" method="runChild" file="BlockJUnit4ClassRunner.java" line="50" exact="true" location="junit-4.11.jar" version="?"/> 89 <ExtendedStackTrace class="org.junit.runners.ParentRunner$3" method="run" file="ParentRunner.java" line="238" exact="true" location="junit-4.11.jar" version="?"/> 90 <ExtendedStackTrace class="org.junit.runners.ParentRunner$1" method="schedule" file="ParentRunner.java" line="63" exact="true" location="junit-4.11.jar" version="?"/> 91 <ExtendedStackTrace class="org.junit.runners.ParentRunner" method="runChildren" file="ParentRunner.java" line="236" exact="true" location="junit-4.11.jar" version="?"/> 92 <ExtendedStackTrace class="org.junit.runners.ParentRunner" method="access$000" file="ParentRunner.java" line="53" exact="true" location="junit-4.11.jar" version="?"/> 93 <ExtendedStackTrace class="org.junit.runners.ParentRunner$2" method="evaluate" file="ParentRunner.java" line="229" exact="true" location="junit-4.11.jar" version="?"/> 94 <ExtendedStackTrace class="org.junit.internal.runners.statements.RunBefores" method="evaluate" file="RunBefores.java" line="26" exact="true" location="junit-4.11.jar" version="?"/> 95 <ExtendedStackTrace class="org.junit.internal.runners.statements.RunAfters" method="evaluate" file="RunAfters.java" line="27" exact="true" location="junit-4.11.jar" version="?"/> 96 <ExtendedStackTrace class="org.junit.runners.ParentRunner" method="run" file="ParentRunner.java" line="309" exact="true" location="junit-4.11.jar" version="?"/> 97 <ExtendedStackTrace class="org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference" method="run" file="JUnit4TestReference.java" line="50" exact="true" location=".cp/" version="?"/> 98 <ExtendedStackTrace class="org.eclipse.jdt.internal.junit.runner.TestExecution" method="run" file="TestExecution.java" line="38" exact="true" location=".cp/" version="?"/> 99 <ExtendedStackTrace class="org.eclipse.jdt.internal.junit.runner.RemoteTestRunner" method="runTests" file="RemoteTestRunner.java" line="467" exact="true" location=".cp/" version="?"/> 100 <ExtendedStackTrace class="org.eclipse.jdt.internal.junit.runner.RemoteTestRunner" method="runTests" file="RemoteTestRunner.java" line="683" exact="true" location=".cp/" version="?"/> 101 <ExtendedStackTrace class="org.eclipse.jdt.internal.junit.runner.RemoteTestRunner" method="run" file="RemoteTestRunner.java" line="390" exact="true" location=".cp/" version="?"/> 102 <ExtendedStackTrace class="org.eclipse.jdt.internal.junit.runner.RemoteTestRunner" method="main" file="RemoteTestRunner.java" line="197" exact="true" location=".cp/" version="?"/> 103 </ExtendedStackTrace> 104 <Suppressed> 105 <Suppressed commonElementCount="0" localizedMessage="I am suppressed exception 1" message="I am suppressed exception 1" name="java.lang.IndexOutOfBoundsException"> 106 <ExtendedStackTrace> 107 <ExtendedStackTrace class="org.apache.logging.log4j.core.layout.LogEventFixtures" method="createLogEvent" file="LogEventFixtures.java" line="57" exact="true" location="test-classes/" version="?"/> 108 <ExtendedStackTrace class="org.apache.logging.log4j.core.layout.XmlLayoutTest" method="testAllFeatures" file="XmlLayoutTest.java" line="122" exact="true" location="test-classes/" version="?"/> 109 <ExtendedStackTrace class="org.apache.logging.log4j.core.layout.XmlLayoutTest" method="testLocationOnCompactOnMdcOn" file="XmlLayoutTest.java" line="270" exact="true" location="test-classes/" version="?"/> 110 <ExtendedStackTrace class="sun.reflect.NativeMethodAccessorImpl" method="invoke" line="-1" exact="false" location="?" version="1.7.0_55"/> 111 <ExtendedStackTrace class="sun.reflect.NativeMethodAccessorImpl" method="invoke" line="-1" exact="false" location="?" version="1.7.0_55"/> 112 <ExtendedStackTrace class="sun.reflect.DelegatingMethodAccessorImpl" method="invoke" line="-1" exact="false" location="?" version="1.7.0_55"/> 113 <ExtendedStackTrace class="java.lang.reflect.Method" method="invoke" line="-1" exact="false" location="?" version="1.7.0_55"/> 114 <ExtendedStackTrace class="org.junit.runners.model.FrameworkMethod$1" method="runReflectiveCall" file="FrameworkMethod.java" line="47" exact="true" location="junit-4.11.jar" version="?"/> 115 <ExtendedStackTrace class="org.junit.internal.runners.model.ReflectiveCallable" method="run" file="ReflectiveCallable.java" line="12" exact="true" location="junit-4.11.jar" version="?"/> 116 <ExtendedStackTrace class="org.junit.runners.model.FrameworkMethod" method="invokeExplosively" file="FrameworkMethod.java" line="44" exact="true" location="junit-4.11.jar" version="?"/> 117 <ExtendedStackTrace class="org.junit.internal.runners.statements.InvokeMethod" method="evaluate" file="InvokeMethod.java" line="17" exact="true" location="junit-4.11.jar" version="?"/> 118 <ExtendedStackTrace class="org.junit.runners.ParentRunner" method="runLeaf" file="ParentRunner.java" line="271" exact="true" location="junit-4.11.jar" version="?"/> 119 <ExtendedStackTrace class="org.junit.runners.BlockJUnit4ClassRunner" method="runChild" file="BlockJUnit4ClassRunner.java" line="70" exact="true" location="junit-4.11.jar" version="?"/> 120 <ExtendedStackTrace class="org.junit.runners.BlockJUnit4ClassRunner" method="runChild" file="BlockJUnit4ClassRunner.java" line="50" exact="true" location="junit-4.11.jar" version="?"/> 121 <ExtendedStackTrace class="org.junit.runners.ParentRunner$3" method="run" file="ParentRunner.java" line="238" exact="true" location="junit-4.11.jar" version="?"/> 122 <ExtendedStackTrace class="org.junit.runners.ParentRunner$1" method="schedule" file="ParentRunner.java" line="63" exact="true" location="junit-4.11.jar" version="?"/> 123 <ExtendedStackTrace class="org.junit.runners.ParentRunner" method="runChildren" file="ParentRunner.java" line="236" exact="true" location="junit-4.11.jar" version="?"/> 124 <ExtendedStackTrace class="org.junit.runners.ParentRunner" method="access$000" file="ParentRunner.java" line="53" exact="true" location="junit-4.11.jar" version="?"/> 125 <ExtendedStackTrace class="org.junit.runners.ParentRunner$2" method="evaluate" file="ParentRunner.java" line="229" exact="true" location="junit-4.11.jar" version="?"/> 126 <ExtendedStackTrace class="org.junit.internal.runners.statements.RunBefores" method="evaluate" file="RunBefores.java" line="26" exact="true" location="junit-4.11.jar" version="?"/> 127 <ExtendedStackTrace class="org.junit.internal.runners.statements.RunAfters" method="evaluate" file="RunAfters.java" line="27" exact="true" location="junit-4.11.jar" version="?"/> 128 <ExtendedStackTrace class="org.junit.runners.ParentRunner" method="run" file="ParentRunner.java" line="309" exact="true" location="junit-4.11.jar" version="?"/> 129 <ExtendedStackTrace class="org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference" method="run" file="JUnit4TestReference.java" line="50" exact="true" location=".cp/" version="?"/> 130 <ExtendedStackTrace class="org.eclipse.jdt.internal.junit.runner.TestExecution" method="run" file="TestExecution.java" line="38" exact="true" location=".cp/" version="?"/> 131 <ExtendedStackTrace class="org.eclipse.jdt.internal.junit.runner.RemoteTestRunner" method="runTests" file="RemoteTestRunner.java" line="467" exact="true" location=".cp/" version="?"/> 132 <ExtendedStackTrace class="org.eclipse.jdt.internal.junit.runner.RemoteTestRunner" method="runTests" file="RemoteTestRunner.java" line="683" exact="true" location=".cp/" version="?"/> 133 <ExtendedStackTrace class="org.eclipse.jdt.internal.junit.runner.RemoteTestRunner" method="run" file="RemoteTestRunner.java" line="390" exact="true" location=".cp/" version="?"/> 134 <ExtendedStackTrace class="org.eclipse.jdt.internal.junit.runner.RemoteTestRunner" method="main" file="RemoteTestRunner.java" line="197" exact="true" location=".cp/" version="?"/> 135 </ExtendedStackTrace> 136 </Suppressed> 137 <Suppressed commonElementCount="0" localizedMessage="I am suppressed exception 2" message="I am suppressed exception 2" name="java.lang.IndexOutOfBoundsException"> 138 <ExtendedStackTrace> 139 <ExtendedStackTrace class="org.apache.logging.log4j.core.layout.LogEventFixtures" method="createLogEvent" file="LogEventFixtures.java" line="58" exact="true" location="test-classes/" version="?"/> 140 <ExtendedStackTrace class="org.apache.logging.log4j.core.layout.XmlLayoutTest" method="testAllFeatures" file="XmlLayoutTest.java" line="122" exact="true" location="test-classes/" version="?"/> 141 <ExtendedStackTrace class="org.apache.logging.log4j.core.layout.XmlLayoutTest" method="testLocationOnCompactOnMdcOn" file="XmlLayoutTest.java" line="270" exact="true" location="test-classes/" version="?"/> 142 <ExtendedStackTrace class="sun.reflect.NativeMethodAccessorImpl" method="invoke" line="-1" exact="false" location="?" version="1.7.0_55"/> 143 <ExtendedStackTrace class="sun.reflect.NativeMethodAccessorImpl" method="invoke" line="-1" exact="false" location="?" version="1.7.0_55"/> 144 <ExtendedStackTrace class="sun.reflect.DelegatingMethodAccessorImpl" method="invoke" line="-1" exact="false" location="?" version="1.7.0_55"/> 145 <ExtendedStackTrace class="java.lang.reflect.Method" method="invoke" line="-1" exact="false" location="?" version="1.7.0_55"/> 146 <ExtendedStackTrace class="org.junit.runners.model.FrameworkMethod$1" method="runReflectiveCall" file="FrameworkMethod.java" line="47" exact="true" location="junit-4.11.jar" version="?"/> 147 <ExtendedStackTrace class="org.junit.internal.runners.model.ReflectiveCallable" method="run" file="ReflectiveCallable.java" line="12" exact="true" location="junit-4.11.jar" version="?"/> 148 <ExtendedStackTrace class="org.junit.runners.model.FrameworkMethod" method="invokeExplosively" file="FrameworkMethod.java" line="44" exact="true" location="junit-4.11.jar" version="?"/> 149 <ExtendedStackTrace class="org.junit.internal.runners.statements.InvokeMethod" method="evaluate" file="InvokeMethod.java" line="17" exact="true" location="junit-4.11.jar" version="?"/> 150 <ExtendedStackTrace class="org.junit.runners.ParentRunner" method="runLeaf" file="ParentRunner.java" line="271" exact="true" location="junit-4.11.jar" version="?"/> 151 <ExtendedStackTrace class="org.junit.runners.BlockJUnit4ClassRunner" method="runChild" file="BlockJUnit4ClassRunner.java" line="70" exact="true" location="junit-4.11.jar" version="?"/> 152 <ExtendedStackTrace class="org.junit.runners.BlockJUnit4ClassRunner" method="runChild" file="BlockJUnit4ClassRunner.java" line="50" exact="true" location="junit-4.11.jar" version="?"/> 153 <ExtendedStackTrace class="org.junit.runners.ParentRunner$3" method="run" file="ParentRunner.java" line="238" exact="true" location="junit-4.11.jar" version="?"/> 154 <ExtendedStackTrace class="org.junit.runners.ParentRunner$1" method="schedule" file="ParentRunner.java" line="63" exact="true" location="junit-4.11.jar" version="?"/> 155 <ExtendedStackTrace class="org.junit.runners.ParentRunner" method="runChildren" file="ParentRunner.java" line="236" exact="true" location="junit-4.11.jar" version="?"/> 156 <ExtendedStackTrace class="org.junit.runners.ParentRunner" method="access$000" file="ParentRunner.java" line="53" exact="true" location="junit-4.11.jar" version="?"/> 157 <ExtendedStackTrace class="org.junit.runners.ParentRunner$2" method="evaluate" file="ParentRunner.java" line="229" exact="true" location="junit-4.11.jar" version="?"/> 158 <ExtendedStackTrace class="org.junit.internal.runners.statements.RunBefores" method="evaluate" file="RunBefores.java" line="26" exact="true" location="junit-4.11.jar" version="?"/> 159 <ExtendedStackTrace class="org.junit.internal.runners.statements.RunAfters" method="evaluate" file="RunAfters.java" line="27" exact="true" location="junit-4.11.jar" version="?"/> 160 <ExtendedStackTrace class="org.junit.runners.ParentRunner" method="run" file="ParentRunner.java" line="309" exact="true" location="junit-4.11.jar" version="?"/> 161 <ExtendedStackTrace class="org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference" method="run" file="JUnit4TestReference.java" line="50" exact="true" location=".cp/" version="?"/> 162 <ExtendedStackTrace class="org.eclipse.jdt.internal.junit.runner.TestExecution" method="run" file="TestExecution.java" line="38" exact="true" location=".cp/" version="?"/> 163 <ExtendedStackTrace class="org.eclipse.jdt.internal.junit.runner.RemoteTestRunner" method="runTests" file="RemoteTestRunner.java" line="467" exact="true" location=".cp/" version="?"/> 164 <ExtendedStackTrace class="org.eclipse.jdt.internal.junit.runner.RemoteTestRunner" method="runTests" file="RemoteTestRunner.java" line="683" exact="true" location=".cp/" version="?"/> 165 <ExtendedStackTrace class="org.eclipse.jdt.internal.junit.runner.RemoteTestRunner" method="run" file="RemoteTestRunner.java" line="390" exact="true" location=".cp/" version="?"/> 166 <ExtendedStackTrace class="org.eclipse.jdt.internal.junit.runner.RemoteTestRunner" method="main" file="RemoteTestRunner.java" line="197" exact="true" location=".cp/" version="?"/> 167 </ExtendedStackTrace> 168 </Suppressed> 169 </Suppressed> 170 </Thrown> 171 </Event> 172 </pre> 173 * <p> 174 * If {@code complete="false"}, the appender does not write the XML processing instruction and the root element. 175 * </p> 176 * <p> 177 * This approach enforces the independence of the XmlLayout and the appender where you embed it. 178 * </p> 179 * <h3>Encoding</h3> 180 * <p> 181 * Appenders using this layout should have their {@code charset} set to {@code UTF-8} or {@code UTF-16}, otherwise events containing non 182 * ASCII characters could result in corrupted log files. 183 * </p> 184 * <h3>Pretty vs. compact XML</h3> 185 * <p> 186 * By default, the XML layout is not compact (compact = not "pretty") with {@code compact="false"}, which means the appender uses 187 * end-of-line characters and indents lines to format the XML. If {@code compact="true"}, then no end-of-line or indentation is used. 188 * Message content may contain, of course, end-of-lines. 189 * </p> 190 */ 191 //CHECKSTYLE:ON 192 @Plugin(name = "XmlLayout", category = Node.CATEGORY, elementType = Layout.ELEMENT_TYPE, printObject = true) 193 public final class XmlLayout extends AbstractJacksonLayout { 194 195 private static final String ROOT_TAG = "Events"; 196 197 protected XmlLayout(final boolean locationInfo, final boolean properties, final boolean complete, final boolean compact, final Charset charset) { 198 super(null, new JacksonFactory.XML().newWriter(locationInfo, properties, compact), charset, compact, complete, false, null, null); 199 } 200 201 /** 202 * Returns appropriate XML headers. 203 * <ol> 204 * <li>XML processing instruction</li> 205 * <li>XML root element</li> 206 * </ol> 207 * 208 * @return a byte array containing the header. 209 */ 210 @Override 211 public byte[] getHeader() { 212 if (!complete) { 213 return null; 214 } 215 final StringBuilder buf = new StringBuilder(); 216 buf.append("<?xml version=\"1.0\" encoding=\""); 217 buf.append(this.getCharset().name()); 218 buf.append("\"?>"); 219 buf.append(this.eol); 220 // Make the log4j namespace the default namespace, no need to use more space with a namespace prefix. 221 buf.append('<'); 222 buf.append(ROOT_TAG); 223 buf.append(" xmlns=\"" + XmlConstants.XML_NAMESPACE + "\">"); 224 buf.append(this.eol); 225 return buf.toString().getBytes(this.getCharset()); 226 } 227 228 /** 229 * Returns appropriate XML footer. 230 * 231 * @return a byte array containing the footer, closing the XML root element. 232 */ 233 @Override 234 public byte[] getFooter() { 235 if (!complete) { 236 return null; 237 } 238 return getBytes("</" + ROOT_TAG + '>' + this.eol); 239 } 240 241 /** 242 * Gets this XmlLayout's content format. Specified by: 243 * <ul> 244 * <li>Key: "dtd" Value: "log4j-events.dtd"</li> 245 * <li>Key: "version" Value: "2.0"</li> 246 * </ul> 247 * 248 * @return Map of content format keys supporting XmlLayout 249 */ 250 @Override 251 public Map<String, String> getContentFormat() { 252 final Map<String, String> result = new HashMap<>(); 253 // result.put("dtd", "log4j-events.dtd"); 254 result.put("xsd", "log4j-events.xsd"); 255 result.put("version", "2.0"); 256 return result; 257 } 258 259 /** 260 * @return The content type. 261 */ 262 @Override 263 public String getContentType() { 264 return "text/xml; charset=" + this.getCharset(); 265 } 266 267 /** 268 * Creates an XML Layout. 269 * 270 * @param locationInfo If "true", includes the location information in the generated XML. 271 * @param properties If "true", includes the thread context map in the generated XML. 272 * @param complete If "true", includes the XML header and footer, defaults to "false". 273 * @param compact If "true", does not use end-of-lines and indentation, defaults to "false". 274 * @param charset The character set to use, if {@code null}, uses "UTF-8". 275 * @return An XML Layout. 276 */ 277 @PluginFactory 278 public static XmlLayout createLayout( 279 // @formatter:off 280 @PluginAttribute(value = "locationInfo", defaultBoolean = false) final boolean locationInfo, 281 @PluginAttribute(value = "properties", defaultBoolean = false) final boolean properties, 282 @PluginAttribute(value = "complete", defaultBoolean = false) final boolean complete, 283 @PluginAttribute(value = "compact", defaultBoolean = false) final boolean compact, 284 @PluginAttribute(value = "charset", defaultString = "UTF-8") final Charset charset) 285 // @formatter:on 286 { 287 return new XmlLayout(locationInfo, properties, complete, compact, charset); 288 } 289 290 /** 291 * Creates an XML Layout using the default settings. 292 * 293 * @return an XML Layout. 294 */ 295 public static XmlLayout createDefaultLayout() { 296 return new XmlLayout(false, false, false, false, StandardCharsets.UTF_8); 297 } 298 }