{"id":58691,"date":"2016-07-25T13:00:48","date_gmt":"2016-07-25T10:00:48","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=58691"},"modified":"2016-07-22T17:18:27","modified_gmt":"2016-07-22T14:18:27","slug":"jaxb-log4j-xml-configuration-files","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2016\/07\/jaxb-log4j-xml-configuration-files.html","title":{"rendered":"JAXB and Log4j XML Configuration Files"},"content":{"rendered":"<p>Both <a href=\"https:\/\/logging.apache.org\/log4j\/1.2\/\">Log4j 1.x<\/a> and <a href=\"http:\/\/logging.apache.org\/log4j\/2.x\/\">Log4j 2.x<\/a> support use of XML files to specify <a href=\"https:\/\/logging.apache.org\/log4j\/2.x\/manual\/configuration.html\">logging configuration<\/a>. This post looks into some of the nuances and subtleties associated with using <a href=\"https:\/\/docs.oracle.com\/javase\/tutorial\/jaxb\/intro\/\">JAXB<\/a> to work with these XML configuration files via Java classes. The examples in this post are based on <a href=\"https:\/\/blogs.apache.org\/logging\/entry\/apache_logging_log4j_1_2\">Apache Log4j 1.2.17<\/a>, <a href=\"https:\/\/blogs.apache.org\/logging\/entry\/log4j_2_6_2_released\">Apache Log4j 2.6.2<\/a>, and <a href=\"http:\/\/www.oracle.com\/technetwork\/java\/javase\/8u73-relnotes-2874654.html\">Java 1.8.0_73<\/a> with JAXB xjc 2.2.8-b130911.1802.<\/p>\n<h2><strong>Log4j 1.x :<\/strong> <code>log4j.dtd<\/code><\/h2>\n<p>Log4j 1.x&#8217;s XML grammar is defined by a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Document_type_definition\">DTD<\/a> instead of an <a href=\"https:\/\/www.w3.org\/standards\/techs\/xmlschema#w3c_all\">W3C XML Schema<\/a>. Fortunately, the JAXB implementation that comes with the JDK provides an &#8220;experimental,unsupported&#8221; option for using DTDs as the input from which Java classes are generated. The following command can be used to run the <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/technotes\/tools\/unix\/xjc.html\">xjc command-line tool<\/a> against the <code>log4j.dtd<\/code>.<\/p>\n<p><code>xjc -p dustin.examples.l4j1 -d src -dtd log4j.dtd<\/code><\/p>\n<p>The next screen snapshot demonstrates this.<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2016\/07\/111.jpg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-58743\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2016\/07\/111.jpg\" alt=\"111\" width=\"557\" height=\"526\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2016\/07\/111.jpg 557w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2016\/07\/111-300x283.jpg 300w\" sizes=\"(max-width: 557px) 100vw, 557px\" \/><\/a><\/p>\n<p>Running the command described above and demonstrated in the screen snapshot leads to Java classes being generated in a Java package in the <code>src<\/code> directory called <code>dustin.examples.l4fj1<\/code> that allow for unmarshalling from <code>log4j.dtd<\/code>-compliant XML and for marshalling to <code>log4j.dtd<\/code>-compliant XML.<\/p>\n<h2><strong>Log4j 2.x : <code>Log4j-config.xsd<\/code><\/strong><\/h2>\n<p>Log4j 2.x&#8217;s <a href=\"https:\/\/logging.apache.org\/log4j\/2.x\/manual\/configuration.html\">XML configuration<\/a> can be either &#8220;concise&#8221; or &#8220;strict&#8221; and I need to use &#8220;<a href=\"http:\/\/stackoverflow.com\/a\/19407812\">strict<\/a>&#8221; in this post because that is the form that uses a grammar defined by the W3C XML Schema file <code>Log4j-config.xsd<\/code> and I <a href=\"http:\/\/stackoverflow.com\/a\/19407812\">need a schema<\/a> to generate Java classes with <a href=\"http:\/\/www.oracle.com\/technetwork\/articles\/javase\/index-140168.html\">JAXB<\/a>. The following command can be run against this XML Schema to generate Java classes representing Log4j2 strict XML.<\/p>\n<p><code>xjc -p dustin.examples.l4j2 -d src Log4j-config.xsd -b l4j2.jxb<\/code><\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2016\/07\/112.jpg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-58744\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2016\/07\/112.jpg\" alt=\"112\" width=\"556\" height=\"374\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2016\/07\/112.jpg 556w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2016\/07\/112-300x202.jpg 300w\" sizes=\"(max-width: 556px) 100vw, 556px\" \/><\/a><\/p>\n<p>Running the above command leads to Java classes being generated in a Java package in the <code>src<\/code> directory called <code>dustin.examples.l4j2<\/code> that allow for unmarshalling from <code>Log4j-config.xsd<\/code>-compliant XML and for marshalling to <code>Log4j-config.xsd<\/code>&#8211;<a href=\"https:\/\/tipsthoughtsnotes.wordpress.com\/2014\/09\/06\/logger4j-2-x-settings\/\">compliant XML<\/a>.<\/p>\n<p>In the previous example, I included a <a href=\"http:\/\/docs.oracle.com\/cd\/E17802_01\/webservices\/webservices\/docs\/1.5\/tutorial\/doc\/JAXBUsing4.html\">JAXB binding file<\/a> with the option <code>-b<\/code> followed by the name of the binding file (<code>-b l4j2.jxb<\/code>). This binding was needed to avoid an error that prevented <code>xjc<\/code> from generated Log4j 2.x-compliant Java classes with the error message, &#8220;Property &#8220;Value&#8221; is already defined. Use &lt;jaxb:property&gt; to resolve this conflict.&#8221; This issue and how to resolve it are discussed in <a href=\"https:\/\/cumbers.wordpress.com\/\">A Brit in Bermuda<\/a>&#8216;s post <a href=\"https:\/\/cumbers.wordpress.com\/2009\/09\/02\/property-value-is-already-defined-use-to-resolve-this-conflict\/\">Property &#8220;Value&#8221; is already defined. Use to resolve this conflict<\/a>. The source for the <a href=\"http:\/\/www.oracle.com\/technetwork\/articles\/marx-jse6-090753.html\">JAXB<\/a> binding file I used here is shown next.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><strong>l4j2.jxb<\/strong><\/p>\n<pre class=\"brush:xml\">&lt;jxb:bindings version=\"2.0\"\r\n              xmlns:jxb=\"http:\/\/java.sun.com\/xml\/ns\/jaxb\"\r\n              xmlns:xsd=\"http:\/\/www.w3.org\/2001\/XMLSchema\"&gt;\r\n   &lt;jxb:bindings schemaLocation=\"Log4j-config.xsd\" node=\"\/xsd:schema\"&gt;\r\n      &lt;jxb:bindings node=\"\/\/xsd:complexType[@name='KeyValuePairType']\"&gt;\r\n         &lt;jxb:bindings node=\".\/\/xsd:attribute[@name='value']\"&gt;\r\n            &lt;jxb:property name=\"pairValue\"\/&gt;\r\n         &lt;\/jxb:bindings&gt;\r\n      &lt;\/jxb:bindings&gt;\r\n   &lt;\/jxb:bindings&gt;\r\n&lt;\/jxb:bindings&gt;<\/pre>\n<p>The JAXB binding file just shown allows <code>xjc<\/code> to successfully parse the XSD and generate the Java classes. The one small price to pay (besides writing and referencing the binding file) is that the &#8220;value&#8221; attribute of the <code>KeyValuePairType<\/code> will need to be accessed in the Java class as a field named <code>pairValue<\/code> instead of <code>value<\/code>.<\/p>\n<h2>Unmarshalling<strong> Log4j 1.x XML<\/strong><\/h2>\n<p>A potential use case for working with JAXB-generated classes for Log4j 1.x&#8217;s <code>log4j.dtd<\/code> and Log4j 2.x&#8217;s <code>Log-config.xsd<\/code> is <a href=\"http:\/\/stackoverflow.com\/questions\/26718495\/lazy-way-to-convert-log4j-xml-to-log4j2-xml\">conversion<\/a> of Log4j 1.x XML configuration files to <a href=\"http:\/\/stackoverflow.com\/questions\/18593430\/migration-from-log4j-1-x-to-log4j2\">Log4j 2.x<\/a> &#8220;strict&#8221; <a href=\"http:\/\/stackoverflow.com\/a\/21206994\">XML configuration files<\/a>. In this situation, one would need to unmarshall Log4j 1.x <code>log4j.dtd<\/code>-compliant XML and marshall Log4j 2.x <code>Log4j-config.xsd<\/code>-compliant XML.<\/p>\n<p>The following code listing demonstrates how the Log4j 1.x XML might be unmarshalled using the previously generated JAXB classes.<\/p>\n<pre class=\"brush:java\">\/**\r\n    * Extract the contents of the Log4j 1.x XML configuration file\r\n    * with the provided path\/name.\r\n    *\r\n    * @param log4j1XmlFileName Path\/name of Log4j 1.x XML config file.\r\n    * @return Contents of Log4j 1.x configuration file.\r\n    * @throws RuntimeException Thrown if exception occurs that prevents\r\n    *    extracting contents from XML with provided name.\r\n    *\/\r\n   public Log4JConfiguration readLog4j1Config(final String log4j1XmlFileName)\r\n      throws RuntimeException\r\n   {\r\n      Log4JConfiguration config;\r\n      try\r\n      {\r\n         final File inputFile = new File(log4j1XmlFileName);\r\n         if (!inputFile.isFile())\r\n         {\r\n            throw new RuntimeException(log4j1XmlFileName + \" is NOT a parseable file.\");\r\n         }\r\n\r\n         final SAXParserFactory spf = SAXParserFactory.newInstance();\r\n         final SAXParser sp = spf.newSAXParser();\r\n         final XMLReader xr = sp.getXMLReader();\r\n         \r\n         final JAXBContext jaxbContext = JAXBContext.newInstance(\"dustin.examples.l4j1\");\r\n         final Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();\r\n         final UnmarshallerHandler unmarshallerHandler = unmarshaller.getUnmarshallerHandler();\r\n         xr.setContentHandler(unmarshallerHandler);\r\n\r\n         final FileInputStream xmlStream = new FileInputStream(log4j1XmlFileName);\r\n         final InputSource xmlSource = new InputSource(xmlStream);\r\n         xr.parse(xmlSource);\r\n\r\n         final Object unmarshalledObject = unmarshallerHandler.getResult();\r\n         config = (Log4JConfiguration) unmarshalledObject;\r\n      }\r\n      catch (JAXBException | ParserConfigurationException | SAXException | IOException exception)\r\n      {\r\n         throw new RuntimeException(\r\n            \"Unable to read from file \" + log4j1XmlFileName + \" - \" + exception,\r\n            exception);\r\n      }\r\n      return config;\r\n   }<\/pre>\n<p>Unmarshalling this Log4j 1.x XML was a bit trickier than some XML unmarshalling because of the nature of <code>log4j.dtd<\/code>&#8216;s namespace treatment. This approach for dealing with this wrinkle is described in <a href=\"http:\/\/gik.firetrot.com\/\">Gik<\/a>&#8216;s <a href=\"http:\/\/gik.firetrot.com\/index.php\/2012\/06\/07\/jaxb-unmarshall-without-namespace\/\">Jaxb UnMarshall without namespace<\/a> and in <a href=\"https:\/\/www.blogger.com\/profile\/17454651506422642481\">Deepa S<\/a>&#8216;s <a href=\"http:\/\/cooljavablogs.blogspot.com\/2008\/08\/how-to-instruct-jaxb-to-ignore.html\">How to instruct JAXB to ignore Namespaces<\/a>. Using this approach helped avoid the error message:<\/p>\n<p><i><br \/>\nUnmarshalException: unexpected element (uri:&#8221;http:\/\/jakarta.apache.org\/log4j\/&#8221;, local:&#8221;configuration&#8221;). Expected elements &#8230;<br \/>\n<\/i><\/p>\n<p>To unmarshall the Log4j 1.x that in my case references <code>log4j.dtd<\/code> on the filesystem, I needed to provide a special Java system property to the Java launcher when running this code with Java 8. Specifically, I needed to specify<br \/>\n<code>-Djavax.xml.accessExternalDTD=all<\/code><br \/>\nto avoid the error message, &#8220;Failed to read external DTD because &#8216;file&#8217; access is not allowed due to restriction set by the <a href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/javax\/xml\/XMLConstants.html#ACCESS_EXTERNAL_DTD\">accessExternalDTD<\/a> property.&#8221; Additional details on this can be found at <a href=\"http:\/\/wiki.netbeans.org\/Main_Page\">NetBeans<\/a>&#8216;s <a href=\"http:\/\/wiki.netbeans.org\/FaqWSDLExternalSchema\">FaqWSDLExternalSchema<\/a> Wiki page.<\/p>\n<h2><strong>Marshalling<\/strong> Log4j<strong> 2.x XML<\/strong><\/h2>\n<p>Marshalling <a href=\"https:\/\/www.grobmeier.de\/the-new-log4j-2-0-05122012.html\">Log4j 2.x<\/a> XML using the JAXB-generated Java classes is fairly straightforward as demonstrated in the following example code:<\/p>\n<pre class=\"brush:java\">\/**\r\n    * Write Log4j 2.x \"strict\" XML configuration to file with\r\n    * provided name based on provided content.\r\n    *\r\n    * @param log4j2Configuration Content to be written to Log4j 2.x\r\n    *    XML configuration file.\r\n    * @param log4j2XmlFile File to which Log4j 2.x \"strict\" XML\r\n    *    configuration should be written.\r\n    *\/\r\n   public void writeStrictLog4j2Config(\r\n      final ConfigurationType log4j2Configuration,\r\n      final String log4j2XmlFile)\r\n   {\r\n      try (final OutputStream os = new FileOutputStream(log4j2XmlFile))\r\n      {\r\n         final JAXBContext jc = JAXBContext.newInstance(\"dustin.examples.l4j2\");\r\n         final Marshaller marshaller = jc.createMarshaller();\r\n         marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);\r\n         marshaller.marshal(new ObjectFactory().createConfiguration(log4j2Configuration), os);\r\n      }\r\n      catch (JAXBException | IOException exception)\r\n      {\r\n         throw new RuntimeException(\r\n            \"Unable to write Log4 2.x XML configuration - \" + exception,\r\n            exception);\r\n      }\r\n   }<\/pre>\n<p>There is one subtlety in this marshalling case that may not be obvious in the just-shown code listing. The classes that JAXB&#8217;s <code>xjc<\/code> generated from the <code>Log4j-config.xsd<\/code> lack any class with <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/javax\/xml\/bind\/annotation\/XmlRootElement.html\">@XmlRootElement<\/a>. The JAXB classes that were generated from the Log4j 1.x <code>log4j.dtd<\/code> did include classes with this <a href=\"http:\/\/blog.bdoughan.com\/2012\/07\/jaxb-and-root-elements.html\">@XmlRootElement<\/a> annotation. Because the Log4j 2.x <code>Log4j-config.xsd<\/code>-based Java classes don&#8217;t have this annotation, the following error occurs when trying to marshal the <code>ConfigurationType<\/code> instance directly:<\/p>\n<blockquote>\n<p><i><br \/>\nMarshalException &#8211; with linked exception: [com.sun.istack.internal.SAXException2: unable to marshal type &#8220;dustin.examples.l4j2.ConfigurationType&#8221; as an element because it is missing an @XmlRootElement annotation]<br \/>\n<\/i><\/p>\n<\/blockquote>\n<p>To avoid this error, I instead (line 18 of above code listing) marshalled the result of invoking <code>new ObjectFactory().createConfiguration(ConfigurationType)<\/code> on the passed-in <code>ConfigurationType<\/code> instance and it is now successfully marshalled.<\/p>\n<h2>Conclusion<\/h2>\n<p>JAXB can be used to generate Java classes from Log4j 1.x&#8217;s <code>log4j.dtd<\/code> and from Log4j 2.x&#8217;s <code>Log4j-config.xsd<\/code>, but there are some subtleties and nuances associated with this process successfully generate these Java classes and to use the generated Java classes to marshal and unmarshal XML.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td><span class=\"reference\">Reference: <\/span><\/td>\n<td><a href=\"http:\/\/marxsoftware.blogspot.com\/2016\/07\/jaxb-and-log4j-xml-configuration-files.html\">JAXB and Log4j XML Configuration Files<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/join-us\/jcg\/\">JCG partner<\/a> Dustin Marx at the <a href=\"http:\/\/marxsoftware.blogspot.com\/\">Inspired by Actual Events <\/a> blog.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Both Log4j 1.x and Log4j 2.x support use of XML files to specify logging configuration. This post looks into some of the nuances and subtleties associated with using JAXB to work with these XML configuration files via Java classes. The examples in this post are based on Apache Log4j 1.2.17, Apache Log4j 2.6.2, and Java &hellip;<\/p>\n","protected":false},"author":122,"featured_media":69,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[144,814,107],"class_list":["post-58691","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-jaxb","tag-log4j","tag-xml"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JAXB and Log4j XML Configuration Files - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Both Log4j 1.x and Log4j 2.x support use of XML files to specify logging configuration. This post looks into some of the nuances and subtleties associated\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2016\/07\/jaxb-log4j-xml-configuration-files.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JAXB and Log4j XML Configuration Files - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Both Log4j 1.x and Log4j 2.x support use of XML files to specify logging configuration. This post looks into some of the nuances and subtleties associated\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2016\/07\/jaxb-log4j-xml-configuration-files.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2016-07-25T10:00:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-log4j-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Dustin Marx\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dustin Marx\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/07\\\/jaxb-log4j-xml-configuration-files.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/07\\\/jaxb-log4j-xml-configuration-files.html\"},\"author\":{\"name\":\"Dustin Marx\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/945db7c24d37de80481570a5643f7958\"},\"headline\":\"JAXB and Log4j XML Configuration Files\",\"datePublished\":\"2016-07-25T10:00:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/07\\\/jaxb-log4j-xml-configuration-files.html\"},\"wordCount\":875,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/07\\\/jaxb-log4j-xml-configuration-files.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/apache-log4j-logo.jpg\",\"keywords\":[\"JAXB\",\"Log4j\",\"XML\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/07\\\/jaxb-log4j-xml-configuration-files.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/07\\\/jaxb-log4j-xml-configuration-files.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/07\\\/jaxb-log4j-xml-configuration-files.html\",\"name\":\"JAXB and Log4j XML Configuration Files - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/07\\\/jaxb-log4j-xml-configuration-files.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/07\\\/jaxb-log4j-xml-configuration-files.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/apache-log4j-logo.jpg\",\"datePublished\":\"2016-07-25T10:00:48+00:00\",\"description\":\"Both Log4j 1.x and Log4j 2.x support use of XML files to specify logging configuration. This post looks into some of the nuances and subtleties associated\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/07\\\/jaxb-log4j-xml-configuration-files.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/07\\\/jaxb-log4j-xml-configuration-files.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/07\\\/jaxb-log4j-xml-configuration-files.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/apache-log4j-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/apache-log4j-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/07\\\/jaxb-log4j-xml-configuration-files.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"JAXB and Log4j XML Configuration Files\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/945db7c24d37de80481570a5643f7958\",\"name\":\"Dustin Marx\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a11cce21db49686299ad9afde297b5213759b39e79a54820195cf16b842639c0?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a11cce21db49686299ad9afde297b5213759b39e79a54820195cf16b842639c0?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a11cce21db49686299ad9afde297b5213759b39e79a54820195cf16b842639c0?s=96&d=mm&r=g\",\"caption\":\"Dustin Marx\"},\"sameAs\":[\"http:\\\/\\\/marxsoftware.blogspot.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Dustin-Marx\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JAXB and Log4j XML Configuration Files - Java Code Geeks","description":"Both Log4j 1.x and Log4j 2.x support use of XML files to specify logging configuration. This post looks into some of the nuances and subtleties associated","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2016\/07\/jaxb-log4j-xml-configuration-files.html","og_locale":"en_US","og_type":"article","og_title":"JAXB and Log4j XML Configuration Files - Java Code Geeks","og_description":"Both Log4j 1.x and Log4j 2.x support use of XML files to specify logging configuration. This post looks into some of the nuances and subtleties associated","og_url":"https:\/\/www.javacodegeeks.com\/2016\/07\/jaxb-log4j-xml-configuration-files.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2016-07-25T10:00:48+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-log4j-logo.jpg","type":"image\/jpeg"}],"author":"Dustin Marx","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Dustin Marx","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2016\/07\/jaxb-log4j-xml-configuration-files.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2016\/07\/jaxb-log4j-xml-configuration-files.html"},"author":{"name":"Dustin Marx","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/945db7c24d37de80481570a5643f7958"},"headline":"JAXB and Log4j XML Configuration Files","datePublished":"2016-07-25T10:00:48+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2016\/07\/jaxb-log4j-xml-configuration-files.html"},"wordCount":875,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2016\/07\/jaxb-log4j-xml-configuration-files.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-log4j-logo.jpg","keywords":["JAXB","Log4j","XML"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2016\/07\/jaxb-log4j-xml-configuration-files.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2016\/07\/jaxb-log4j-xml-configuration-files.html","url":"https:\/\/www.javacodegeeks.com\/2016\/07\/jaxb-log4j-xml-configuration-files.html","name":"JAXB and Log4j XML Configuration Files - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2016\/07\/jaxb-log4j-xml-configuration-files.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2016\/07\/jaxb-log4j-xml-configuration-files.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-log4j-logo.jpg","datePublished":"2016-07-25T10:00:48+00:00","description":"Both Log4j 1.x and Log4j 2.x support use of XML files to specify logging configuration. This post looks into some of the nuances and subtleties associated","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2016\/07\/jaxb-log4j-xml-configuration-files.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2016\/07\/jaxb-log4j-xml-configuration-files.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2016\/07\/jaxb-log4j-xml-configuration-files.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-log4j-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-log4j-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2016\/07\/jaxb-log4j-xml-configuration-files.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"JAXB and Log4j XML Configuration Files"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/945db7c24d37de80481570a5643f7958","name":"Dustin Marx","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/a11cce21db49686299ad9afde297b5213759b39e79a54820195cf16b842639c0?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/a11cce21db49686299ad9afde297b5213759b39e79a54820195cf16b842639c0?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a11cce21db49686299ad9afde297b5213759b39e79a54820195cf16b842639c0?s=96&d=mm&r=g","caption":"Dustin Marx"},"sameAs":["http:\/\/marxsoftware.blogspot.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/Dustin-Marx"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/58691","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/122"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=58691"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/58691\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/69"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=58691"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=58691"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=58691"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}