Author: eric
Date: Thu May 10 17:02:27 2012
New Revision: 1336796

URL: http://svn.apache.org/viewvc?rev=1336796&view=rev
Log:
More documentation regarding logging in mailets

Modified:
    james/server/trunk/src/site/xdoc/dev-extend-mailet.xml

Modified: james/server/trunk/src/site/xdoc/dev-extend-mailet.xml
URL: 
http://svn.apache.org/viewvc/james/server/trunk/src/site/xdoc/dev-extend-mailet.xml?rev=1336796&r1=1336795&r2=1336796&view=diff
==============================================================================
--- james/server/trunk/src/site/xdoc/dev-extend-mailet.xml (original)
+++ james/server/trunk/src/site/xdoc/dev-extend-mailet.xml Thu May 10 17:02:27 
2012
@@ -57,6 +57,28 @@ methods.</p>
 <p>The value of getMailetInfo() for the Mailet is prepended to the log entries 
for that 
 Mailet.  So it may be desirable for you to override this method so you can 
distinguish mailet
 log entries by Mailet.</p>
+<p>Alternatively, you can instanciate your own logger and log with different 
level, as show in the
+following snippet (don't forget to update the log4j.properties so you log are 
taken into account).</p>
+<code>
+package com.test;
+
+import javax.mail.MessagingException;
+
+import org.apache.mailet.Mail;
+import org.apache.mailet.base.GenericMailet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MyMailet extends GenericMailet{
+  private static final Logger logger = LoggerFactory.getLogger(MyMailet.class);
+  @Override
+  public void service(Mail mail) throws MessagingException {
+    log("log via mailet logger with INFO level");
+    logger.info("Log via slf4j with INFO level !!! Add 
log4j.logger.com.test=INFO, CONS, FILE in the log4j.properties");
+    logger.debug("Log via slf4j with DEBUG level !!! Add 
log4j.logger.com.test=DEBUG, CONS, FILE in the log4j.properties");
+  }
+}
+</code>
 </subsection>
 
 <subsection name="Initialization">



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to