{"id":20303,"date":"2013-05-10T12:49:26","date_gmt":"2013-05-10T07:19:26","guid":{"rendered":"http:\/\/vskills.in\/certification\/tutorial\/?p=20303"},"modified":"2024-04-12T14:16:40","modified_gmt":"2024-04-12T08:46:40","slug":"using-log4j-for-logging","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/using-log4j-for-logging\/","title":{"rendered":"Using Log4J for logging"},"content":{"rendered":"<p><a class=\"vsc\" href=\"http:\/\/www.vskills.in\/certification\/Certified-Cassandra-Professional\"><span class=\"vsc-cn\" style=\"text-align: center;\"><span style=\"color: red;\">Certify and Increase Opportunity.<\/span><br \/>\n<span style=\"color: green;\">Be <\/span><br \/>\nGovt. Certified Apache Cassandra Professional<br \/>\n<\/span><\/a><\/p>\n<p>Using Log4J for logging<\/p>\n<p style=\"text-align: center;\"><a ref=\"magnificPopup\" href=\"http:\/\/vskills.in\/certification\/tutorial\/wp-content\/uploads\/2013\/05\/log4j.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-40052\" src=\"http:\/\/vskills.in\/certification\/tutorial\/wp-content\/uploads\/2013\/05\/log4j.jpg\" alt=\"log4j\" width=\"207\" height=\"139\"><\/a><\/p>\n<p>Apache log4j is a Java-based logging framework that provides runtime application feedback. It provides the ability to control the granularity of log statements using an external configuration file (log4j.properties).<\/p>\n<p>The log4j utility has three main components: loggers, appenders, and layouts. Loggers are logical log file names. They are the names known to the Java application. Each logger is independently configurable for the level of logging. Outputs are controlled by Appenders. Numerous Appenders are available and multiple Appenders can be attached to any Logger. This makes it possible to log the same information to multiple outputs. Appenders use Layouts to format log entries.<\/p>\n<p><span style=\"text-decoration: underline;\">Log Levels<\/span><br \/>\nThe available levels are:<\/p>\n<ul>\n<li>All &#8211; turn on all logging<\/li>\n<li>OFF &#8211; no logging<\/li>\n<li>FATAL &#8211; severe errors causing premature termination<\/li>\n<li>ERROR &#8211; other runtime errors or unexpected conditions<\/li>\n<li>WARN &#8211; use of deprecated APIs, poor use of API, near errors, and other undesirable or unexpected runtime situations<\/li>\n<li>DEBUG &#8211; detailed information on the flow through the system<\/li>\n<li>TRACE &#8211; more detailed than DEBUG<\/li>\n<li>INFO &#8211; highlight the progress of the application at a coarse-grained level<\/li>\n<\/ul>\n<p><span style=\"text-decoration: underline;\">Log Messages<\/span><br \/>\nThe messages that appear in the log are controlled via the conf\/log4j.properties file. Using this properties file, you can control the granularity to the Java package and class levels. For example, DEBUG messages from a particular class can be included in the log while messages from others remain at a higher level. This is helpful to reduce clutter and to identify messages. The log is most commonly a file and\/or stdout. The format, behavior (such as file rolling), and so on is also configurable at runtime.<\/p>\n<p>Below are sample log messages from a Cassandra node startup:<\/p>\n<p>INFO [main] 2012-02-10 09:15:33,112 DatabaseDescriptor.java (line 495)<br \/>\nFound table data in data directories. Consider using the CLI to define your schema.<br \/>\nINFO [main] 2012-02-10 09:15:33,135 CommitLog.java (line 166)<br \/>\nNo commitlog files found; skipping replay<br \/>\nINFO [main] 2012-02-10 09:15:33,150 StorageService.java (line 400)<br \/>\nCassandra version: 1.0.7<br \/>\nINFO [main] 2012-02-10 09:15:33,150 StorageService.java (line 401)<br \/>\nThrift API version: 19.20.0<br \/>\nINFO [main] 2012-02-10 09:15:33,150 StorageService.java (line 414)<br \/>\nLoading persisted ring state<br \/>\n&#8230;<\/p>\n<p><span style=\"text-decoration: underline;\">Storing log4j Messages in a Column Family<\/span><br \/>\nThe Cassandra Appender provides the capability to store log4j messages in a Cassandra column family. To enable the Cassandra Appender:<\/p>\n<p>Add resources\/log4j-appender\/lib\/ to your application classpath.<\/p>\n<p>Modify the conf\/log4j.properties file, as shown in the example below:<\/p>\n<p># Cassandra Appender<br \/>\nlog4j.appender.CASS=com.datastax.logging.appender.CassandraAppender<br \/>\nlog4j.appender.CASS.hosts = 127.0.0.1<br \/>\nlog4j.appender.CASS.port = 9160<br \/>\n#log4j.appender.CASS.appName = &#8220;myApp&#8221;<br \/>\n#log4j.appender.CASS.keyspaceName = &#8220;Logging&#8221;<br \/>\n#log4j.appender.CASS.columnFamily = &#8220;log_entries&#8221;<br \/>\n#log4j.appender.CASS.placementStrategy =<br \/>\n&#8220;org.apache.cassandra.locator.NetworkTopologyStrategy&#8221;<br \/>\n#log4j.appender.CASS.strategyOptions = {&#8220;DC1&#8221; : &#8220;1&#8221;, &#8220;DC2&#8221; : &#8220;3&#8221; }<br \/>\n#log4j.appender.CASS.replicationFactor = 1<br \/>\n#log4j.appender.CASS.consistencyLevelWrite = ONE<br \/>\n#log4j.appender.CASS.maxBufferedRows = 256<\/p>\n<p>log4j.logger.com.foo.bar= INFO, CASS<\/p>\n<p>Commented lines are included for reference and to show the default values.<\/p>\n<p>log4j.appender.CASS=com.datastax.logging.appender.CassandraAppender specifies the CassandraAppender class and assigns it the CASS alias. This alias is referenced in the last line.<\/p>\n<p>log4j.appender.CASS.hosts = 127.0.0.1 allows using a comma delimited list of Cassandra nodes (in case a node goes down).<\/p>\n<p>Specify replication options in lines:<\/p>\n<p>log4j.appender.CASS.placementStrategy = &#8220;org.apache.cassandra.locator.NetworkTopologyStrategy&#8221; log4j.appender.CASS.strategyOptions = {&#8220;DC1&#8221; : &#8220;1&#8221;, &#8220;DC2&#8221; : &#8220;3&#8221; }.<\/p>\n<div class=\"apply\">\n<h3>Apply for Apache Cassandra Certification Now!!<\/h3>\n<p><a href=\"http:\/\/www.vskills.in\/certification\/Certified-Cassandra-Professional\">http:\/\/www.vskills.in\/certification\/Certified-Apache-Cassandra-Professional<\/a><\/p>\n<h5>Go To Tutorial-&nbsp;<a href=\"https:\/\/www.vskills.in\/certification\/tutorial\/apache-cassandra-professional\/\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>Certified Apache Cassandra Professional Tutorial<\/strong><\/a><\/h5>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Certify and Increase Opportunity. Be Govt. Certified Apache Cassandra Professional Using Log4J for logging Apache log4j is a Java-based logging framework that provides runtime application feedback. It provides the ability to control the granularity of log statements using an external configuration file (log4j.properties). The log4j utility has three main components: loggers, appenders, and layouts. Loggers&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[63],"tags":[],"class_list":["post-20303","page","type-page","status-publish","hentry","category-apache-cassandra"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Using Log4J for logging - Tutorial<\/title>\n<meta name=\"description\" content=\"Using Log4J for logging. Vskills Government Certification in Apache Cassandra is very popular in India amongst developers working in the IT Bid data industry.\" \/>\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.vskills.in\/certification\/tutorial\/using-log4j-for-logging\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using Log4J for logging - Tutorial\" \/>\n<meta property=\"og:description\" content=\"Using Log4J for logging. Vskills Government Certification in Apache Cassandra is very popular in India amongst developers working in the IT Bid data industry.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/using-log4j-for-logging\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vskills.in\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-12T08:46:40+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/vskills.in\/certification\/tutorial\/wp-content\/uploads\/2013\/05\/log4j.jpg\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/using-log4j-for-logging\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/using-log4j-for-logging\/\",\"name\":\"Using Log4J for logging - Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/using-log4j-for-logging\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/using-log4j-for-logging\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/vskills.in\/certification\/tutorial\/wp-content\/uploads\/2013\/05\/log4j.jpg\",\"datePublished\":\"2013-05-10T07:19:26+00:00\",\"dateModified\":\"2024-04-12T08:46:40+00:00\",\"description\":\"Using Log4J for logging. Vskills Government Certification in Apache Cassandra is very popular in India amongst developers working in the IT Bid data industry.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/using-log4j-for-logging\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/using-log4j-for-logging\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/using-log4j-for-logging\/#primaryimage\",\"url\":\"http:\/\/vskills.in\/certification\/tutorial\/wp-content\/uploads\/2013\/05\/log4j.jpg\",\"contentUrl\":\"http:\/\/vskills.in\/certification\/tutorial\/wp-content\/uploads\/2013\/05\/log4j.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/using-log4j-for-logging\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using Log4J for logging\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"name\":\"Tutorial\",\"description\":\"Vskills - A initiative in elearning and certification\",\"publisher\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\",\"name\":\"Vskills\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"width\":73,\"height\":55,\"caption\":\"Vskills\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/vskills.in\/\",\"https:\/\/x.com\/vskills_in\",\"https:\/\/www.linkedin.com\/company-beta\/1371554\/\",\"https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using Log4J for logging - Tutorial","description":"Using Log4J for logging. Vskills Government Certification in Apache Cassandra is very popular in India amongst developers working in the IT Bid data industry.","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.vskills.in\/certification\/tutorial\/using-log4j-for-logging\/","og_locale":"en_US","og_type":"article","og_title":"Using Log4J for logging - Tutorial","og_description":"Using Log4J for logging. Vskills Government Certification in Apache Cassandra is very popular in India amongst developers working in the IT Bid data industry.","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/using-log4j-for-logging\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","article_modified_time":"2024-04-12T08:46:40+00:00","og_image":[{"url":"http:\/\/vskills.in\/certification\/tutorial\/wp-content\/uploads\/2013\/05\/log4j.jpg","type":"","width":"","height":""}],"twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/using-log4j-for-logging\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/using-log4j-for-logging\/","name":"Using Log4J for logging - Tutorial","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/using-log4j-for-logging\/#primaryimage"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/using-log4j-for-logging\/#primaryimage"},"thumbnailUrl":"http:\/\/vskills.in\/certification\/tutorial\/wp-content\/uploads\/2013\/05\/log4j.jpg","datePublished":"2013-05-10T07:19:26+00:00","dateModified":"2024-04-12T08:46:40+00:00","description":"Using Log4J for logging. Vskills Government Certification in Apache Cassandra is very popular in India amongst developers working in the IT Bid data industry.","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/using-log4j-for-logging\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/using-log4j-for-logging\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/using-log4j-for-logging\/#primaryimage","url":"http:\/\/vskills.in\/certification\/tutorial\/wp-content\/uploads\/2013\/05\/log4j.jpg","contentUrl":"http:\/\/vskills.in\/certification\/tutorial\/wp-content\/uploads\/2013\/05\/log4j.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/using-log4j-for-logging\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Using Log4J for logging"}]},{"@type":"WebSite","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","name":"Tutorial","description":"Vskills - A initiative in elearning and certification","publisher":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization","name":"Vskills","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","width":73,"height":55,"caption":"Vskills"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/vskills.in\/","https:\/\/x.com\/vskills_in","https:\/\/www.linkedin.com\/company-beta\/1371554\/","https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw"]}]}},"_links":{"self":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/20303","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/comments?post=20303"}],"version-history":[{"count":12,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/20303\/revisions"}],"predecessor-version":[{"id":122117,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/20303\/revisions\/122117"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=20303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=20303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=20303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}