{"id":14883,"date":"2014-09-30T15:00:00","date_gmt":"2014-09-30T12:00:00","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=14883"},"modified":"2014-09-30T10:16:32","modified_gmt":"2014-09-30T07:16:32","slug":"log4j-rootlogger-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/","title":{"rendered":"log4j rootlogger example"},"content":{"rendered":"<p>In this example we shall talk about the <code>rootlogger<\/code>, which is a basic component in <code><a href=\"http:\/\/logging.apache.org\/log4j\/1.2\/\" target=\"_blank\">Log4j<\/a><\/code>. Log4j a thread-safe and flexible logging library for Java, licensed under the Apache Software Foundation.<\/p>\n<p>The basic components of the log4j architecture are the <code>loggers<\/code>, the <code>appenders<\/code> and the <code>layouts<\/code>. <code>Loggers<\/code> are used to log the messages, <code>appenders<\/code> to publish the messages to different outputs and <code>layouts<\/code> to format the log messages. All these components are configured in the <code>log4j.properties<\/code> file, which is placed in the application <code>classpath<\/code>. <\/p>\n<p>The basic logger that sits at the top of the logger hierarchy is the <code>rootlogger<\/code>. <a href=\"https:\/\/logging.apache.org\/log4j\/1.2\/apidocs\/org\/apache\/log4j\/spi\/RootLogger.html\" target=\"_blank\"><code>RootLogger<\/code><\/a> is a regular logger, although it cannot be assigned a <code>null<\/code> level and since it cannot have a parent, the <code>getChainedLevel()<\/code> API method always returns the value of the level field without walking the hierarchy. Also, the <code>rootLogger<\/code> cannot be retrieved by name. It can only be retrieved by invoking the <code>static getRootLogger()<\/code> API method of <a href=\"https:\/\/logging.apache.org\/log4j\/1.2\/apidocs\/org\/apache\/log4j\/Logger.html\" target=\"_blank\"><code>Logger<\/code><\/a>. All other loggers are instantiated and retrieved with the class static  <code>getLogger(String name)<\/code> API method of <a  ref=\"https:\/\/logging.apache.org\/log4j\/1.2\/apidocs\/org\/apache\/log4j\/Logger.html\" target=\"_blank\"><code>Logger<\/code><\/a>, which takes the name of the desired logger as a parameter. <\/p>\n<p>Below, we have created an example with a class that uses the <code>rootlogger<\/code> to log messages to the console. <\/p>\n<div class=\"tip\"><strong>Tip<\/strong><br \/>You may skip project creation and jump directly to the <a href=\"#code\"><strong>beginning of the example<\/strong><\/a> below.<\/div>\n<p>Our preferred development environment is <a href=\"http:\/\/www.eclipse.org\/\" target=\"_blank\">Eclipse<\/a>. We are using Eclipse Juno (4.2) version, along with <a href=\"http:\/\/maven.apache.org\/\" target=\"_blank\">Maven<\/a> Integration plugin version 3.1.0. You can download Eclipse from <a href=\"http:\/\/www.eclipse.org\/downloads\/\" target=\"_blank\">here<\/a> and Maven Plugin for Eclipse from <a href=\"http:\/\/maven.apache.org\/eclipse-plugin.html\" target=\"_blank\">here<\/a>. The installation of Maven plugin for Eclipse is out of the scope of this tutorial and will not be discussed. We are also using the JDK 7_u_21.<\/p>\n<p>Let&#8217;s begin,<\/p>\n<h2>1. Create a new Maven project<\/h2>\n<p>Go to File -&gt; Project -&gt;Maven -&gt; Maven Project.<\/p>\n<p><figure id=\"attachment_4341\" aria-describedby=\"caption-attachment-4341\" style=\"width: 521px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/06\/New-Maven-Project.png\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/06\/New-Maven-Project.png\" alt=\"New Maven Project\" width=\"521\" height=\"504\" class=\"size-full wp-image-4341\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/06\/New-Maven-Project.png 521w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/06\/New-Maven-Project-300x290.png 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/06\/New-Maven-Project-42x42.png 42w\" sizes=\"(max-width: 521px) 100vw, 521px\" \/><\/a><figcaption id=\"caption-attachment-4341\" class=\"wp-caption-text\">New Maven Project &#8211; step 1<\/figcaption><\/figure><\/p>\n<p>In the &#8220;Select project name and location&#8221; page of the wizard, make sure that &#8220;Create a simple project (skip archetype selection)&#8221; option is <strong>checked<\/strong>, hit &#8220;Next&#8221; to continue with default values.<\/p>\n<p><figure id=\"attachment_4342\" aria-describedby=\"caption-attachment-4342\" style=\"width: 603px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/06\/Maven-Project-Name-Location.png\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/06\/Maven-Project-Name-Location.png\" alt=\"New Maven Project 2\" width=\"603\" height=\"550\" class=\"size-full wp-image-4342\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/06\/Maven-Project-Name-Location.png 603w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/06\/Maven-Project-Name-Location-300x273.png 300w\" sizes=\"(max-width: 603px) 100vw, 603px\" \/><\/a><figcaption id=\"caption-attachment-4342\" class=\"wp-caption-text\">New Maven Project 2<\/figcaption><\/figure><div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>In the &#8220;Enter an artifact id&#8221; page of the wizard, you can define the name and main package of your project. We will set the &#8220;Group Id&#8221; variable to <code>\"com.javacodegeeks.snippets.enterprise\"<\/code> and the &#8220;Artifact Id&#8221; variable to <code>\"log4jexample\"<\/code>. The aforementioned selections compose the main project package as <code>\"com.javacodegeeks.snippets.enterprise.log4jexample \"<\/code> and the project name as <code>\"log4jexample\"<\/code>. Hit &#8220;Finish&#8221; to exit the wizard and to create your project.<\/p>\n<p><figure id=\"attachment_14720\" aria-describedby=\"caption-attachment-14720\" style=\"width: 603px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/09\/log4jexample.png\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/09\/log4jexample.png\" alt=\"log4j example \" width=\"603\" height=\"552\" class=\"size-full wp-image-14720\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/09\/log4jexample.png 603w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/09\/log4jexample-300x274.png 300w\" sizes=\"(max-width: 603px) 100vw, 603px\" \/><\/a><figcaption id=\"caption-attachment-14720\" class=\"wp-caption-text\">log4j example<\/figcaption><\/figure><\/p>\n<p>The Maven project structure is shown below:<\/p>\n<p><figure id=\"attachment_14721\" aria-describedby=\"caption-attachment-14721\" style=\"width: 409px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/09\/log4jexample2.png\"><img decoding=\"async\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/09\/log4jexample2.png\" alt=\"log4j example structure\" width=\"409\" height=\"435\" class=\"size-full wp-image-14721\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/09\/log4jexample2.png 409w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/09\/log4jexample2-282x300.png 282w\" sizes=\"(max-width: 409px) 100vw, 409px\" \/><\/a><figcaption id=\"caption-attachment-14721\" class=\"wp-caption-text\">log4j example structure<\/figcaption><\/figure><\/p>\n<ul>It consists of the following folders:<\/p>\n<li>\/src\/main\/java folder, that contains source files for the dynamic content of the application,<\/li>\n<li>\/src\/test\/java folder contains all source files for unit tests,<\/li>\n<li>\/src\/main\/resources folder contains configurations files,<\/li>\n<li>\/target folder contains the compiled and packaged deliverables,<\/li>\n<li>the pom.xml is the project object model (POM) file. The single file that contains all project related configuration.<\/li>\n<\/ul>\n<h2>2. Add log4j dependency<\/h2>\n<p>Add the <code>log4j<\/code> dependency in Maven\u2019s <code>pom.xml<\/code> file, by editing it at the &#8220;Pom.xml&#8221; page of the POM editor, as shown below:<br \/>\n&nbsp;<br \/>\n<span style=\"text-decoration: underline;\"><em>pom.xml:<\/em><\/span><\/p>\n<pre class=\"brush:xml\">\r\n&lt;project xmlns=&quot;http:\/\/maven.apache.org\/POM\/4.0.0&quot; xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot;\r\n\txsi:schemaLocation=&quot;http:\/\/maven.apache.org\/POM\/4.0.0 http:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd&quot;&gt;\r\n\t&lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\r\n\t&lt;groupId&gt;com.javacodegeeks.snippets.enterprise&lt;\/groupId&gt;\r\n\t&lt;artifactId&gt;log4jexample&lt;\/artifactId&gt;\r\n\t&lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt;\r\n\t&lt;dependencies&gt;\r\n\t\t&lt;dependency&gt;\r\n\t\t\t&lt;groupId&gt;log4j&lt;\/groupId&gt;\r\n\t\t\t&lt;artifactId&gt;log4j&lt;\/artifactId&gt;\r\n\t\t\t&lt;version&gt;1.2.17&lt;\/version&gt;\r\n\t\t&lt;\/dependency&gt;\r\n\t&lt;\/dependencies&gt;\r\n&lt;\/project&gt;\r\n<\/pre>\n<p>As you can see Maven manages library dependencies declaratively. A local repository is created (by default under {user_home}\/.m2 folder) and all required libraries are downloaded and placed there from public repositories. Furthermore intra \u2013 library dependencies are automatically resolved and manipulated.<\/p>\n<p><span id=\"code\"\/><\/p>\n<h2> 3. Create the log4j.properties file <\/h2>\n<p>The <code>log4j.properties<\/code> file is placed under the <code>resources<\/code> folder of the project. This is where all logging components are configured. The <code>rootLogger<\/code> is set here, binded to a logging level and an appender. The <code>rootlogger<\/code> is always the logger configured in the <code>log4j.properties<\/code> file, so every child logger used in the application inherits the configuration of the <code>rootlogger<\/code>. <\/p>\n<p>The logging levels are (from smaller to greater) : <code>ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF<\/code>. When a logging level is set, only messages belonging to this level or greater levels are printed. <\/p>\n<p>Here, we use an appender to log messages to the console. It uses the <code>org.apache.log4j.ConsoleAppender<\/code>.  It has a <code>target<\/code> attribute which is set to <code>System.out<\/code> and uses a layout for the logging messages. The <code>org.apache.log4j.PatternLayout<\/code> is used and the <code>ConversionPattern<\/code> is set to <code>%d{dd\/MMM\/yyyy HH:mm:ss,SSS}- %c{1}: %m%n<\/code>.<\/p>\n<p><code>%d{dd\/MMM\/yyyy HH:mm:ss,SSS}<\/code> is used to set the date pattern, <code>%c{1}<\/code> is used to print the class name, <code>%m<\/code> to print the message, and <code>%n<\/code> to leave an empty line.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>log4j.properties<\/em><\/span><\/p>\n<pre class=\"brush:xml\">\r\nlog4j.rootLogger = INFO, stdout\r\n\r\nlog4j.appender.stdout=org.apache.log4j.ConsoleAppender\r\nlog4j.appender.stdout.Target=System.out\r\nlog4j.appender.stdout.layout=org.apache.log4j.PatternLayout\r\nlog4j.appender.stdout.layout.ConversionPattern=%d{dd\/MMM\/yyyy HH:mm:ss,SSS}- %c{1}: %m%n\r\n\r\n<\/pre>\n<h2>4. Create an Example class<\/h2>\n<p><code>Example.java<\/code> class gets the <code>rootLogger<\/code> to log messages to the console. The logger is stated as a <code>static<\/code> field, initialized by the <code>getRootLogger()<\/code> API method of <code>org.apache.log4j.Logger<\/code>. <code>Example.java<\/code> class has a main method, where the user is asked to type number. The logger first logs messages of different levels, using <code>info(Object message)<\/code>, <code>warn(Object message)<\/code>, <code>debug(Object message)<\/code>, <code>error( Object message)<\/code> and <code>fatal(Object message)<\/code> API methods of <a href=\"https:\/\/logging.apache.org\/log4j\/1.2\/apidocs\/org\/apache\/log4j\/Category.html\" target=\"_blank\"><code>org.apache.log4j.Category<\/code><\/a>.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Example.java:<\/em><\/span><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.snippets.enterprise.log4jexample;\r\n\r\nimport java.io.BufferedReader;\r\nimport java.io.IOException;\r\nimport java.io.InputStreamReader;\r\n\r\nimport org.apache.log4j.Level;\r\nimport org.apache.log4j.Logger;\r\n\r\npublic class Example {\r\n\r\n\tstatic Logger log = Logger.getRootLogger();\r\n\r\n\tpublic static void main(String[] args) throws IOException {\r\n\t\tSystem.out.println(&quot;===&gt; Please enter a number:\\n===&gt;&quot;);\r\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\r\n\t\tint number = Integer.valueOf(br.readLine());\r\n\t\tlog.info(&quot;Info : number is &quot; + number);\r\n\t\tlog.warn(&quot;Warning : number is &quot; + number);\r\n\t\tlog.debug(&quot;Debug : number is &quot; + number);\r\n\t\tlog.error(&quot;Error : number is &quot; + number);\r\n\t\tlog.fatal(&quot;Fatal : number is &quot; + number);\r\n\t}\r\n}\r\n<\/pre>\n<h2>5. Run the application<\/h2>\n<p>Run the application. The result in the console will be something like the one below: <\/p>\n<pre style=\"background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;\"><code style=\"color: black; word-wrap: normal;\">===> Please enter a number:\r\n===>\r\n2\r\n30\/Sep\/2014 00:29:21,605- root: Info : number is 2\r\n30\/Sep\/2014 00:29:21,659- root: Warning : number is 2\r\n30\/Sep\/2014 00:29:21,659- root: Error : number is 2\r\n30\/Sep\/2014 00:29:21,659- root: Fatal : number is 2\r\n<\/code><\/pre>\n<p>As you can see, since the log level is set to <code>INFO<\/code>, only info, warning, error and fatal messages are printed. You can change the logging level and see what happens.<\/p>\n<h2>6. Download the Eclipse Project<\/h2>\n<p>This was an example of <code><a href=\"http:\/\/logging.apache.org\/log4j\/1.2\/\" target=\"_blank\">Log4j<\/a><\/code> <code>rootlogger<\/code>.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>You can download the full source code of this example here: <strong><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/09\/log4jRootLoggerExample.zip\">log4jRootLoggerExample<\/a><\/strong><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this example we shall talk about the rootlogger, which is a basic component in Log4j. Log4j a thread-safe and flexible logging library for Java, licensed under the Apache Software Foundation. The basic components of the log4j architecture are the loggers, the appenders and the layouts. Loggers are used to log the messages, appenders to &hellip;<\/p>\n","protected":false},"author":5,"featured_media":13304,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[649],"tags":[1099],"class_list":["post-14883","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-log4j","tag-logging"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>log4j rootlogger example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"In this example we shall talk about the rootlogger, which is a basic component in Log4j. Log4j a thread-safe and flexible logging library for Java,\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"log4j rootlogger example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"In this example we shall talk about the rootlogger, which is a basic component in Log4j. Log4j a thread-safe and flexible logging library for Java,\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2014-09-30T12:00:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/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=\"Theodora Fragkouli\" \/>\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=\"Theodora Fragkouli\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/\"},\"author\":{\"name\":\"Theodora Fragkouli\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/2f9f5246a40f628c77a0b72499c1e697\"},\"headline\":\"log4j rootlogger example\",\"datePublished\":\"2014-09-30T12:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/\"},\"wordCount\":834,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/apache-log4j-logo.jpg\",\"keywords\":[\"logging\"],\"articleSection\":[\"Log4j\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/\",\"name\":\"log4j rootlogger example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/apache-log4j-logo.jpg\",\"datePublished\":\"2014-09-30T12:00:00+00:00\",\"description\":\"In this example we shall talk about the rootlogger, which is a basic component in Log4j. Log4j a thread-safe and flexible logging library for Java,\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/apache-log4j-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/apache-log4j-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Log4j\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/log4j\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"log4j rootlogger example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/2f9f5246a40f628c77a0b72499c1e697\",\"name\":\"Theodora Fragkouli\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Theodora-Fragkouli.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Theodora-Fragkouli.jpg\",\"caption\":\"Theodora Fragkouli\"},\"description\":\"Theodora has graduated from Computer Engineering and Informatics Department in the University of Patras. She also holds a Master degree in Economics from the National and Technical University of Athens. During her studies she has been involved with a large number of projects ranging from programming and software engineering to telecommunications, hardware design and analysis. She works as a junior Software Engineer in the telecommunications sector where she is mainly involved with projects based on Java and Big Data technologies.\",\"sameAs\":[\"http:\/\/www.javacodegeeks.com\/\",\"https:\/\/gr.linkedin.com\/pub\/theodora-fragkouli\/66\/19\/983\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/theodora-fragkouli\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"log4j rootlogger example - Java Code Geeks","description":"In this example we shall talk about the rootlogger, which is a basic component in Log4j. Log4j a thread-safe and flexible logging library for Java,","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:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/","og_locale":"en_US","og_type":"article","og_title":"log4j rootlogger example - Java Code Geeks","og_description":"In this example we shall talk about the rootlogger, which is a basic component in Log4j. Log4j a thread-safe and flexible logging library for Java,","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2014-09-30T12:00:00+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/apache-log4j-logo.jpg","type":"image\/jpeg"}],"author":"Theodora Fragkouli","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Theodora Fragkouli","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/"},"author":{"name":"Theodora Fragkouli","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/2f9f5246a40f628c77a0b72499c1e697"},"headline":"log4j rootlogger example","datePublished":"2014-09-30T12:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/"},"wordCount":834,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/apache-log4j-logo.jpg","keywords":["logging"],"articleSection":["Log4j"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/","name":"log4j rootlogger example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/apache-log4j-logo.jpg","datePublished":"2014-09-30T12:00:00+00:00","description":"In this example we shall talk about the rootlogger, which is a basic component in Log4j. Log4j a thread-safe and flexible logging library for Java,","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/apache-log4j-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/apache-log4j-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-rootlogger-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/"},{"@type":"ListItem","position":4,"name":"Log4j","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/log4j\/"},{"@type":"ListItem","position":5,"name":"log4j rootlogger example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/2f9f5246a40f628c77a0b72499c1e697","name":"Theodora Fragkouli","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Theodora-Fragkouli.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Theodora-Fragkouli.jpg","caption":"Theodora Fragkouli"},"description":"Theodora has graduated from Computer Engineering and Informatics Department in the University of Patras. She also holds a Master degree in Economics from the National and Technical University of Athens. During her studies she has been involved with a large number of projects ranging from programming and software engineering to telecommunications, hardware design and analysis. She works as a junior Software Engineer in the telecommunications sector where she is mainly involved with projects based on Java and Big Data technologies.","sameAs":["http:\/\/www.javacodegeeks.com\/","https:\/\/gr.linkedin.com\/pub\/theodora-fragkouli\/66\/19\/983"],"url":"https:\/\/examples.javacodegeeks.com\/author\/theodora-fragkouli\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/14883","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=14883"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/14883\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/13304"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=14883"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=14883"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=14883"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}