{"id":6203,"date":"2012-08-24T13:34:07","date_gmt":"2012-08-24T08:04:07","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=6203"},"modified":"2016-12-19T15:30:57","modified_gmt":"2016-12-19T10:00:57","slug":"manage-multiple-log-file","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/manage-multiple-log-file\/","title":{"rendered":"Manage Multiple Log File"},"content":{"rendered":"<h4><strong> Different Levels of Logging to Different Appenders or Files:<\/strong><\/h4>\n<p style=\"padding:10px\">\n<p>When a project is running, then lot of log messages (all type of log messages e.g. Error, Fatal, Warning, Info, Debug etc.) are logged into a single log file. Many times we try to find the error messages only, instead of debugging the complete application. In that case we manage more than one log files.<\/p>\n<p style=\"padding:10px\">\n<h5><strong>Two simple steps to define multiple log files according to log level priority:<\/strong><\/h5>\n<p style=\"padding:10px\">\n<p><strong>1<\/strong>. In <strong>appender block<\/strong> of<strong> log4j block<\/strong> in <strong>Config.groovy<\/strong>, add the appenders according to the number of log files. Here I have created two different log files, first one is for debug level logs and second one is for error level logs.<\/p>\n<p>[groovy]<br \/>\n\/**<br \/>\n  * In appenders block, generated log file name will be with file attribute,<br \/>\n  * and log level will define with threshold.<br \/>\n  **\/<br \/>\nappenders {<br \/>\n        rollingFile name:&#8217;debugLog&#8217;, file:&#8217;debug.log&#8217;, threshold: org.apache.log4j.Level.DEBUG<br \/>\n        rollingFile name:&#8217;errorLog&#8217;, file:&#8217;error.log&#8217;, threshold: org.apache.log4j.Level.ERROR<br \/>\n}<br \/>\n[\/groovy]<\/p>\n<p><strong>2.<\/strong> declare all the appenders in <strong>root block<\/strong> of<strong> log4j block<\/strong> in <strong>Config.groovy<\/strong> file as:<br \/>\n[groovy]<br \/>\nroot {<br \/>\n        info &#8216;debugLog&#8217;, &#8216;errorLog&#8217;<br \/>\n}<br \/>\n[\/groovy]<\/p>\n<p style=\"padding:10px\">\n<p>Thats it. \ud83d\ude42<\/p>\n<p style=\"padding:10px\">\n<p><strong>Note:<\/strong> When we are using log level files, then log level file will contain all that log level messages of that priority level and priority level above that.<\/p>\n<p>Amit Kumar<br \/>\n<a href=\"http:\/\/www.tothenew.com\/blog\/author\/amit.kumar\/\">amit.kumar@intelligrape.com<\/a><br \/>\nin.linkedin.com\/in\/amitkumar0110<br \/>\ntwitter.com\/amit_kumar0110<br \/>\n<strong><a href=\"http:\/\/www.tothenew.com\/blog\/author\/amit-kumar\/\">More Blogs by Me<\/a><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Different Levels of Logging to Different Appenders or Files: When a project is running, then lot of log messages (all type of log messages e.g. Error, Fatal, Warning, Info, Debug etc.) are logged into a single log file. Many times we try to find the error messages only, instead of debugging the complete application. In [&hellip;]<\/p>\n","protected":false},"author":52,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":8},"categories":[7],"tags":[4840,471,869,867],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/6203"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/52"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=6203"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/6203\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=6203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=6203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=6203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}