{"id":14717,"date":"2014-09-25T11:00:25","date_gmt":"2014-09-25T08:00:25","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=14717"},"modified":"2014-09-30T00:11:57","modified_gmt":"2014-09-29T21:11:57","slug":"log4j-properties-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-example\/","title":{"rendered":"log4j properties example"},"content":{"rendered":"<p>This is an example of how to configure <code>log4j<\/code>, using the <code>log4j.properties<\/code> file. <code><a href=\"http:\/\/logging.apache.org\/log4j\/1.2\/\" target=\"_blank\">Log4j<\/a><\/code> is a logging library for Java, licensed under the Apache Software Foundation. It is a Logging Framework that is thread-safe and flexible, thanks to its configuration. With <code>log4j<\/code> you can configure logging in runtime, and you can log to different outputs, such as files or even databases.<\/p>\n<p>Basically, it consists of <code>loggers<\/code> 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 classpath. <\/p>\n<p>Below, we have created an example with a class that uses a logger to log messages to a file and 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><\/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><div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/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>\tAdd the log4j 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. First, the <code>rootLogger<\/code> is where the logging level and the appender that will be used are set. 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 two appenders, one appender to log to a file and another one to log to the console. The first appender uses the <code>org.apache.log4j.FileAppender<\/code> and the second one the <code>org.apache.log4j.ConsoleAppender<\/code>. The first appender has a <code>file<\/code> attribute, where the logging file is set, whereas the second one has a <code>target<\/code> attribute which is set to <code>System.out<\/code>. Both appenders use a layout for their log files. 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, File, stdout\r\n\r\nlog4j.appender.File=org.apache.log4j.FileAppender\r\nlog4j.appender.File.File=C:\\\\logs\\\\logs.log\r\nlog4j.appender.File.layout=org.apache.log4j.PatternLayout\r\nlog4j.appender.File.layout.conversionPattern=%d{dd\/MMM\/yyyy HH:mm:ss,SSS}- %c{1}: %m%n\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 uses a <code>org.apache.log4j.Logger<\/code> to log messages both to a file and to the console. The logger is stated as a <code>static<\/code> field, initialized by the <code>getLogger(String name)<\/code> API method of <code>org.apache.log4j.Logger<\/code>, making use of the classe&#8217;s name. <code>Example.java<\/code> class has a main method, where the user is asked to type number between 0 and 100. The logger first logs an info message, using <code>info(Object message)<\/code> API method of <code>org.apache.log4j.Logger<\/code>. If the number is greater than 100, an exception is thrown and the logger logs an error message, making use of <code>error( Object message)<\/code> API method of <code>org.apache.log4j.Logger<\/code>. If the number is lower than 100, then the logger logs a debug message, with <code>debug(Object message)<\/code> API method of <code>org.apache.log4j.Logger<\/code>.<\/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.Logger;\r\n\r\npublic class Example {\r\n\r\n\tstatic Logger log = Logger.getLogger(Example.class.getName());\r\n\r\n\tpublic static void main(String[] args) throws IOException{\r\n\t\tSystem.out.println(&quot;====&gt; Please insert a number from 0 to 100 : \\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;You inserted the number:&quot;+number);\r\n\t\tif(number &gt; 100) {\r\n\t\t\tlog.error(&quot;You entered a wrong number!&quot;);\r\n\t\t\tthrow new IOException();\r\n\t\t} else {\r\n\t\t\tlog.debug(&quot;Number is smaller than 100, so it is correct!&quot;);\r\n\t\t}\r\n\t}\r\n}\r\n<\/pre>\n<h2>5. Run the application<\/h2>\n<p>Run the application, typing a number greater than 100. The result in the console will be 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 insert a number from 0 to 100 : \r\n====> \r\n456\r\n25\/Sep\/2014 01:17:58,176- Example: You inserted the number:456\r\nException in thread \"main\" 25\/Sep\/2014 01:17:58,178- Example: You entered a wrong number!\r\njava.io.IOException\r\n\tat com.javacodegeeks.snippets.enterprise.log4jexample.Example.main(Example.java:20)\r\n<\/code><\/pre>\n<p>And the log file is the one below:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>logs.log:<\/em><\/span><\/p>\n<pre class=\"brush:xml\">25\/Sep\/2014 01:17:58,176- Example: You inserted the number:456\r\n25\/Sep\/2014 01:17:58,178- Example: You entered a wrong number!\r\n<\/pre>\n<p>As you can see, since the log level is set to <code>INFO<\/code>, only info and error messages are printed. You can change the logging level to <code>DEBUG<\/code> and <code>ERROR<\/code> and see what happens. Then you can try the same steps, typing a correct number to see what happens.<\/p>\n<h2>6. Download the Eclipse Project<\/h2>\n<p>This was an example of how to configure log4j with <code>log4j.properties<\/code> file.<\/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\/log4jPropertiesExample.zip\">log4jPropertiesExample<\/a><\/strong><\/div>\n","protected":false},"excerpt":{"rendered":"<p>This is an example of how to configure log4j, using the log4j.properties file. Log4j is a logging library for Java, licensed under the Apache Software Foundation. It is a Logging Framework that is thread-safe and flexible, thanks to its configuration. With log4j you can configure logging in runtime, and you can log to different outputs, &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-14717","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 properties example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"This is an example of how to configure log4j, using the log4j.properties file. Log4j is a logging library for Java, licensed under the Apache Software\" \/>\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-properties-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"log4j properties example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"This is an example of how to configure log4j, using the log4j.properties file. Log4j is a logging library for Java, licensed under the Apache Software\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-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-25T08:00:25+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-09-29T21:11:57+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=\"7 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-properties-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-example\/\"},\"author\":{\"name\":\"Theodora Fragkouli\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/2f9f5246a40f628c77a0b72499c1e697\"},\"headline\":\"log4j properties example\",\"datePublished\":\"2014-09-25T08:00:25+00:00\",\"dateModified\":\"2014-09-29T21:11:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-example\/\"},\"wordCount\":869,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-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-properties-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-example\/\",\"name\":\"log4j properties example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/apache-log4j-logo.jpg\",\"datePublished\":\"2014-09-25T08:00:25+00:00\",\"dateModified\":\"2014-09-29T21:11:57+00:00\",\"description\":\"This is an example of how to configure log4j, using the log4j.properties file. Log4j is a logging library for Java, licensed under the Apache Software\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-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-properties-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 properties 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 properties example - Java Code Geeks","description":"This is an example of how to configure log4j, using the log4j.properties file. Log4j is a logging library for Java, licensed under the Apache Software","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-properties-example\/","og_locale":"en_US","og_type":"article","og_title":"log4j properties example - Java Code Geeks","og_description":"This is an example of how to configure log4j, using the log4j.properties file. Log4j is a logging library for Java, licensed under the Apache Software","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2014-09-25T08:00:25+00:00","article_modified_time":"2014-09-29T21:11:57+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":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-example\/"},"author":{"name":"Theodora Fragkouli","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/2f9f5246a40f628c77a0b72499c1e697"},"headline":"log4j properties example","datePublished":"2014-09-25T08:00:25+00:00","dateModified":"2014-09-29T21:11:57+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-example\/"},"wordCount":869,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-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-properties-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-example\/","name":"log4j properties example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/apache-log4j-logo.jpg","datePublished":"2014-09-25T08:00:25+00:00","dateModified":"2014-09-29T21:11:57+00:00","description":"This is an example of how to configure log4j, using the log4j.properties file. Log4j is a logging library for Java, licensed under the Apache Software","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/log4j\/log4j-properties-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-properties-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 properties 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\/14717","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=14717"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/14717\/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=14717"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=14717"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=14717"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}