{"id":595,"date":"2011-10-28T22:00:00","date_gmt":"2011-10-28T22:00:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/log4j-stat4j-smtpappender-integration-aggregating-error-logs-to-send-email-when-too-many.html"},"modified":"2012-10-21T20:22:39","modified_gmt":"2012-10-21T20:22:39","slug":"log4j-stat4j-smtpappender-integration","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2011\/10\/log4j-stat4j-smtpappender-integration.html","title":{"rendered":"Log4j, Stat4j, SMTPAppender Integration &#8211; Aggregating Error Logs to Send Email When Too Many"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\">Our development team wanted to get notified as soon as something goes wrong in our production system, a critical Java web application serving thousands of customers daily. The idea was to let it send us an email when there are too many errors, indicating usually a problem with a database, an external web service, or something really bad with the application itself.<\/p>\n<p>In this post I want to present a simple solution we have implemented using a custom Log4J Appender based on Stats4j and an SMTPAppender (which is more difficult to configure and troubleshoot than you might expect).<\/p>\n<p><strong>The Challenge<\/strong><\/p>\n<p>We faced the following challenges with the logs:<\/p>\n<ul style=\"text-align: left\">\n<li>It\u2019s unfortunately normal to have certain number of exceptions (customers select search criteria yielding no results, temporary, unimportant outages of external services etc.) and we certainly don\u2019t want to be spammed because of that. So the solution must have a configurable threshold and only send an alert when it is exceeded.<\/li>\n<li>The failure rate should be computed for a configurable period (long enough not to trigger an alert because of few-minutes outages yet short enough for the team to be informed ASAP when something serious happens).<\/li>\n<li>Once an alert is send, no further alerts should be send again for some time (ideally until the original problem is fixed), we don\u2019t want to be spammed because of a problem we already know about.<\/li>\n<\/ul>\n<p><strong>The Solution<\/strong><\/p>\n<p>We\u2019ve based our solution on Lara D\u2019Abreo\u2019s <a href=\"http:\/\/sourceforge.net\/projects\/stat4j\/\">Stat4J<\/a>, which provides a custom Log4J appender that uses the logs to compute configurable measures and triggers alerts when they exceed their warning or critical thresholds. It is couple of years old, alpha-quality (regarding its generality and flexibility) open-source library, which is fortunately simple enough to be modified easily for one\u2019s needs.<\/p>\n<p>So we have tweaked Stat4J to produce alerts when the number of alerts exceeds thresholds and keep quiet thereafter and combined that with a Log4J <a href=\"http:\/\/logging.apache.org\/log4j\/1.2\/apidocs\/org\/apache\/log4j\/net\/SMTPAppender.html\">SMTPAppender<\/a> that listens for the alerts and sends them via e-mail to the team.<\/p>\n<p><strong>Stat4J Tweaking<\/strong><\/p>\n<p>The key components of Stat4J are the Stat4jAppender for Log4J itself, calculators (measures) that aggregate the individual logs (e.g. by counting them or extracting some number form them), statistics that define which logs to consider via regular expressions and how to process them by referencing a calculator, and finally alerts that log a warning when the value of a statistics exceeds its limits. You can learn more in an <a href=\"http:\/\/www.devx.com\/java\/Article\/22110\/0\/page\/3\">article that introduces Stat4J<\/a>.<\/p>\n<p>We have implemented a custom measure calculator, <a href=\"https:\/\/github.com\/jakubholynet\/blog\/blob\/master\/stat4j\/src\/net\/sourceforge\/stat4j\/calculators\/RunningRate.java\">RunningRate<\/a> (to count the number of failures in the last N minutes) and modified Stat4J as  follows:<\/p>\n<ul style=\"text-align: left\">\n<li>We\u2019ve <a href=\"https:\/\/github.com\/jakubholynet\/blog\/blob\/master\/stat4j\/src\/net\/sourceforge\/stat4j\/Alert.java#L124\">enhanced Alert<\/a> to support a new attribute, quietperiod, so that once triggered, subsequent alerts will be ignored for that duration (unless the previous alert was just a warning while the new one is a critical one)<\/li>\n<li>We\u2019ve modified the appender to <a href=\"https:\/\/github.com\/jakubholynet\/blog\/blob\/master\/stat4j\/src\/net\/sourceforge\/stat4j\/log4j\/Stat4jAppender.java#L53\">include the log\u2019s Throwable<\/a> together with the log message, which is then passed to the individual statistics calculators, so that we could filter more precisely what we want to count<\/li>\n<li>Finally we\u2019ve modified Alert to <a href=\"https:\/\/github.com\/jakubholynet\/blog\/blob\/master\/stat4j\/src\/net\/sourceforge\/stat4j\/Alert.java#L92\">log alerts<\/a> as errors instead of warnings so that  the SMTPAppender wouldn\u2019t ignore them<\/li>\n<\/ul>\n<p>Get our <a href=\"https:\/\/github.com\/jakubholynet\/blog\/tree\/master\/stat4j\">modified Stat4j from GitHub<\/a> (sources or a <a href=\"https:\/\/github.com\/jakubholynet\/blog\/downloads\">compiled jar<\/a>). Disclaimer: It is one day\u2019s hack and I\u2019m not proud of the code.<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>Stat4J Configuration<\/strong><\/p>\n<p>Take the <a href=\"https:\/\/github.com\/jakubholynet\/blog\/blob\/master\/stat4j\/test\/stat4j.properties\">example stat4j.properties<\/a> and put it on the classpath. It is already configured with the correct calculator, statistics, and alert. See this part:<\/p>\n<pre class=\"brush: bash\">### JAKUB HOLY - MY CONFIG\r\ncalculator.minuteRate.classname=net.sourceforge.stat4j.calculators.RunningRate\r\n# Period is in [ms] 1000 * 60 * 10 = 10 min:\r\ncalculator.minuteRate.period=600000\r\n\r\nstatistic.RunningErrorRate.description=Errors per 10 minutes\r\nstatistic.RunningErrorRate.calculator=minuteRate\r\n# Regular expression to match \"&lt;throwable.toString&gt; &lt;- &lt;original log message&gt;\"\r\nstatistic.RunningErrorRate.first.match=.*Exception.*\r\n\r\n# Error Rate\r\nalert.TooManyErrorsRecently.description=Too many errors in the log\r\nalert.TooManyErrorsRecently.statistic=RunningErrorRate\r\nalert.TooManyErrorsRecently.warn= &gt;=3\r\nalert.TooManyErrorsRecently.critical= &gt;=10\r\nalert.TooManyErrorsRecently.category=alerts\r\n# Ignore following warnings (or criticals, after the first critical) for the given amount of time:\r\n# 1000 * 60 * 100 = 100 min\r\nalert.TooManyErrorsRecently.quietperiod=6000000\r\n<\/pre>\n<p>The important config params are<\/p>\n<ul style=\"text-align: left\">\n<li><i>calculator.minuteRate.period<\/i> (in ms) \u2013 count errors over this period, reset the count at its end; a reasonable value may be 10 minutes<\/li>\n<li><i>alert.TooManyErrorsRecently.warn<\/i> and <i>alert.TooManyErrorsRecently.critical<\/i> \u2013 trigger the alert when so many errors in the period has been encountered; reasonable values depend on your application\u2019s normal error rate<\/li>\n<li><i>alert.TooManyErrorsRecently.quietperiod<\/i> (in ms) \u2013 don\u2019t send further alerts for this period not to spam in a persistent failure situation; the reasonable value depends on how quickly you usually fix problems, 1 hour would seem OK to me<\/li>\n<\/ul>\n<p><strong>Log4J Configuration<\/strong><\/p>\n<p>Now we need to tell Log4J to use the Stat4j appender to count error occurences and to send alerts via email:<\/p>\n<pre class=\"brush:bash\">log4j.rootCategory=DEBUG, Console, FileAppender, Stat4jAppender\r\n...\r\n### Stat4jAppender &amp; EmailAlertsAppender ###\r\n# Collects statistics about logs and sends alerts when there\r\n# were too many failures in cooperation with the EmailAlertsAppender\r\n\r\n## Stat4jAppender\r\nlog4j.appender.Stat4jAppender=net.sourceforge.stat4j.log4j.Stat4jAppender\r\nlog4j.appender.Stat4jAppender.Threshold=ERROR\r\n# For configuration see stat4j.properties\r\n\r\n## EmailAlertsAppender\r\n# BEWARE: SMTPAppender ignores its Thresholds and only evers sends ERROR or higher messages\r\nlog4j.category.alerts=ERROR, EmailAlertsAppender\r\nlog4j.appender.EmailAlertsAppender=org.apache.log4j.net.SMTPAppender\r\nlog4j.appender.EmailAlertsAppender.To=dummy@example.com\r\n# BEWARE: The address below must have a valid domain or some receivers will reject it (e.g. GMail)\r\nlog4j.appender.EmailAlertsAppender.From=noreply-stat4j@google.no\r\nlog4j.appender.EmailAlertsAppender.SMTPHost=172.20.20.70\r\nlog4j.appender.EmailAlertsAppender.BufferSize=1\r\nlog4j.appender.EmailAlertsAppender.Subject=[Stat4j] Too many exceptions in log\r\nlog4j.appender.EmailAlertsAppender.layout=org.apache.log4j.PatternLayout\r\nlog4j.appender.EmailAlertsAppender.layout.ConversionPattern=%d{ISO8601} %-5p %X{clientIdentifier} %c %x - %m%n\r\n<\/pre>\n<p><strong>Comments<\/strong><\/p>\n<ul style=\"text-align: left\">\n<li>#8 Specify the Stat4J appender<\/li>\n<li>#9 Only send ERRORs to Stat4J, we are not interested in less serious exceptions<\/li>\n<li>#14 \u201calerts\u201d is the log category used by Stat4jAppender to log alerts (the same you would create via Logger.getLogger(\u201calerts\u201d)); as mentioned, SMTPAppender will without respect to the configuration only process ERRORs and higher<\/li>\n<\/ul>\n<p><strong>Issues with the SMTPAppender<\/strong><\/p>\n<p>It is quite tricky to get the SMTPAppender working. Some pitfalls:<\/p>\n<ul style=\"text-align: left\">\n<li>SMTPAppender ignores all logs that are not ERROR or higher without respect to how you set its threshold<\/li>\n<li>If you specify a non-existing From domain then some recipient\u2019s mail servers can just delete the email as spam (e.g. GMail)<\/li>\n<li>To send emails, you of course need mail.jar (and for older JVMs also activation.jar), here are <a href=\"http:\/\/haveacafe.wordpress.com\/2008\/09\/26\/113\/\">instructions for Tomcat<\/a><\/li>\n<\/ul>\n<p>And one $100 tip: to debug it, run your application in the debug mode and set a method breakpoint on javax.mail.Transport#send (you don\u2019t need the source code) and when there, set this.session.debug to true to get a very detailed log of the following SMTP communication in the server log.<\/p>\n<p><strong>Sidenote<\/strong><\/p>\n<p>The fact that this article is based on Log4J doesn\u2019t mean I\u2019d personally choose it, it just came with the project. I\u2019d at least consider using the newer and shiny Logback instead :-) .<\/p>\n<p><strong>Conclusion<\/strong><\/p>\n<p>Stat4j + SMTPAppender are a very good base for a rather flexible do-it-yourself alerting system based on logs and e-mail. You can achieve the same thing out-out-the-box with Hyperic HQ plus. <\/p>\n<p><strong><i>Reference: <\/i><\/strong><a href=\"http:\/\/theholyjava.wordpress.com\/2011\/10\/15\/aggregating-error-logs-to-send-a-warning-email-when-too-many-of-them-log4j-stat4j-smtpappender\/\">Aggregating Error Logs to Send a Warning Email When Too Many of Them \u2013 Log4j, Stat4j, SMTPAppender<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a> <a href=\"http:\/\/theholyjava.wordpress.com\/about\/\">Jakub Hol\u00fd<\/a> at <a href=\"http:\/\/theholyjava.wordpress.com\/\">&#8220;The Holy Java&#8221; Blog<\/a>.<\/p>\n<div style=\"margin: 0px\"><strong><i>Related Articles :<\/i><\/strong><\/div>\n<ul>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/09\/logging-exceptions-root-cause-first.html\">Logging exceptions root cause first<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/09\/java-logging-mess.html\">The Java Logging Mess<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/01\/10-tips-proper-application-logging.html\">10 Tips for Proper Application Logging<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/10\/sending-emails-with-java.html\">Sending emails with Java<\/a> <\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/06\/spring-quartz-javamail-tutorial.html\">Spring, Quartz and JavaMail Integration Tutorial<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/07\/java-mail-spring-gmail-smtp.html\">Sending e-mails in Java with Spring \u2013 GMail SMTP server example<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/p\/java-tutorials.html\">Java Tutorials and Android Tutorials list<\/a> <\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Our development team wanted to get notified as soon as something goes wrong in our production system, a critical Java web application serving thousands of customers daily. The idea was to let it send us an email when there are too many errors, indicating usually a problem with a database, an external web service, or &hellip;<\/p>\n","protected":false},"author":16,"featured_media":69,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[284,132,283],"class_list":["post-595","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-apache-log4j","tag-logging","tag-stat4j"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Log4j, Stat4j, SMTPAppender Integration - Aggregating Error Logs to Send Email When Too Many - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Our development team wanted to get notified as soon as something goes wrong in our production system, a critical Java web application serving thousands of\" \/>\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\/2011\/10\/log4j-stat4j-smtpappender-integration.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Log4j, Stat4j, SMTPAppender Integration - Aggregating Error Logs to Send Email When Too Many - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Our development team wanted to get notified as soon as something goes wrong in our production system, a critical Java web application serving thousands of\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2011\/10\/log4j-stat4j-smtpappender-integration.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=\"2011-10-28T22:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-21T20:22:39+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=\"Jakub Holy\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@http:\/\/twitter.com\/HolyJak\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jakub Holy\" \/>\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\\\/2011\\\/10\\\/log4j-stat4j-smtpappender-integration.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/10\\\/log4j-stat4j-smtpappender-integration.html\"},\"author\":{\"name\":\"Jakub Holy\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/7b7d87e493b5f8388635d4315b062727\"},\"headline\":\"Log4j, Stat4j, SMTPAppender Integration &#8211; Aggregating Error Logs to Send Email When Too Many\",\"datePublished\":\"2011-10-28T22:00:00+00:00\",\"dateModified\":\"2012-10-21T20:22:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/10\\\/log4j-stat4j-smtpappender-integration.html\"},\"wordCount\":1066,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/10\\\/log4j-stat4j-smtpappender-integration.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/apache-log4j-logo.jpg\",\"keywords\":[\"Apache Log4j\",\"Logging\",\"Stat4j\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/10\\\/log4j-stat4j-smtpappender-integration.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/10\\\/log4j-stat4j-smtpappender-integration.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/10\\\/log4j-stat4j-smtpappender-integration.html\",\"name\":\"Log4j, Stat4j, SMTPAppender Integration - Aggregating Error Logs to Send Email When Too Many - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/10\\\/log4j-stat4j-smtpappender-integration.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/10\\\/log4j-stat4j-smtpappender-integration.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/apache-log4j-logo.jpg\",\"datePublished\":\"2011-10-28T22:00:00+00:00\",\"dateModified\":\"2012-10-21T20:22:39+00:00\",\"description\":\"Our development team wanted to get notified as soon as something goes wrong in our production system, a critical Java web application serving thousands of\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/10\\\/log4j-stat4j-smtpappender-integration.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/10\\\/log4j-stat4j-smtpappender-integration.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/10\\\/log4j-stat4j-smtpappender-integration.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\\\/2011\\\/10\\\/log4j-stat4j-smtpappender-integration.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\":\"Log4j, Stat4j, SMTPAppender Integration &#8211; Aggregating Error Logs to Send Email When Too Many\"}]},{\"@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\\\/7b7d87e493b5f8388635d4315b062727\",\"name\":\"Jakub Holy\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7ee9569bd027b442ce03e2cc44cbc8791448ab502e0e2c70cbc6186f64d6e1f5?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7ee9569bd027b442ce03e2cc44cbc8791448ab502e0e2c70cbc6186f64d6e1f5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7ee9569bd027b442ce03e2cc44cbc8791448ab502e0e2c70cbc6186f64d6e1f5?s=96&d=mm&r=g\",\"caption\":\"Jakub Holy\"},\"description\":\"Jakub is an experienced Java[EE] developer working for a lean &amp; agile consultancy in Norway. He is interested in code quality, developer productivity, testing, and in how to make projects succeed.\",\"sameAs\":[\"http:\\\/\\\/theholyjava.wordpress.com\",\"http:\\\/\\\/www.linkedin.com\\\/in\\\/jakubholydotnet\",\"https:\\\/\\\/x.com\\\/http:\\\/\\\/twitter.com\\\/HolyJak\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Jakub-Holy\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Log4j, Stat4j, SMTPAppender Integration - Aggregating Error Logs to Send Email When Too Many - Java Code Geeks","description":"Our development team wanted to get notified as soon as something goes wrong in our production system, a critical Java web application serving thousands of","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\/2011\/10\/log4j-stat4j-smtpappender-integration.html","og_locale":"en_US","og_type":"article","og_title":"Log4j, Stat4j, SMTPAppender Integration - Aggregating Error Logs to Send Email When Too Many - Java Code Geeks","og_description":"Our development team wanted to get notified as soon as something goes wrong in our production system, a critical Java web application serving thousands of","og_url":"https:\/\/www.javacodegeeks.com\/2011\/10\/log4j-stat4j-smtpappender-integration.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2011-10-28T22:00:00+00:00","article_modified_time":"2012-10-21T20:22:39+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":"Jakub Holy","twitter_card":"summary_large_image","twitter_creator":"@http:\/\/twitter.com\/HolyJak","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Jakub Holy","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2011\/10\/log4j-stat4j-smtpappender-integration.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/10\/log4j-stat4j-smtpappender-integration.html"},"author":{"name":"Jakub Holy","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/7b7d87e493b5f8388635d4315b062727"},"headline":"Log4j, Stat4j, SMTPAppender Integration &#8211; Aggregating Error Logs to Send Email When Too Many","datePublished":"2011-10-28T22:00:00+00:00","dateModified":"2012-10-21T20:22:39+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/10\/log4j-stat4j-smtpappender-integration.html"},"wordCount":1066,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/10\/log4j-stat4j-smtpappender-integration.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-log4j-logo.jpg","keywords":["Apache Log4j","Logging","Stat4j"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2011\/10\/log4j-stat4j-smtpappender-integration.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2011\/10\/log4j-stat4j-smtpappender-integration.html","url":"https:\/\/www.javacodegeeks.com\/2011\/10\/log4j-stat4j-smtpappender-integration.html","name":"Log4j, Stat4j, SMTPAppender Integration - Aggregating Error Logs to Send Email When Too Many - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/10\/log4j-stat4j-smtpappender-integration.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/10\/log4j-stat4j-smtpappender-integration.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-log4j-logo.jpg","datePublished":"2011-10-28T22:00:00+00:00","dateModified":"2012-10-21T20:22:39+00:00","description":"Our development team wanted to get notified as soon as something goes wrong in our production system, a critical Java web application serving thousands of","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/10\/log4j-stat4j-smtpappender-integration.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2011\/10\/log4j-stat4j-smtpappender-integration.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2011\/10\/log4j-stat4j-smtpappender-integration.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\/2011\/10\/log4j-stat4j-smtpappender-integration.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":"Log4j, Stat4j, SMTPAppender Integration &#8211; Aggregating Error Logs to Send Email When Too Many"}]},{"@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\/7b7d87e493b5f8388635d4315b062727","name":"Jakub Holy","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/7ee9569bd027b442ce03e2cc44cbc8791448ab502e0e2c70cbc6186f64d6e1f5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/7ee9569bd027b442ce03e2cc44cbc8791448ab502e0e2c70cbc6186f64d6e1f5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/7ee9569bd027b442ce03e2cc44cbc8791448ab502e0e2c70cbc6186f64d6e1f5?s=96&d=mm&r=g","caption":"Jakub Holy"},"description":"Jakub is an experienced Java[EE] developer working for a lean &amp; agile consultancy in Norway. He is interested in code quality, developer productivity, testing, and in how to make projects succeed.","sameAs":["http:\/\/theholyjava.wordpress.com","http:\/\/www.linkedin.com\/in\/jakubholydotnet","https:\/\/x.com\/http:\/\/twitter.com\/HolyJak"],"url":"https:\/\/www.javacodegeeks.com\/author\/Jakub-Holy"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/595","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\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=595"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/595\/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=595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}