You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by "Stefano Bagnara (JIRA)" <se...@james.apache.org> on 2006/09/25 20:27:52 UTC

[jira] Resolved: (JAMES-601) Add Class detail in logs of James.Mailet (patch)

     [ http://issues.apache.org/jira/browse/JAMES-601?page=all ]

Stefano Bagnara resolved JAMES-601.
-----------------------------------

    Fix Version/s: Trunk
       Resolution: Fixed
         Assignee: Stefano Bagnara

I also:
1) updated the default server.xml to log mailetpackages and matcherpackages logs to the mailet logfile.
2) removed the MailetName prefix used by GenericMailet and GenericMatcher when logging (we already have that informationin the logger name, now)

> Add Class detail in logs of James.Mailet (patch)
> ------------------------------------------------
>
>                 Key: JAMES-601
>                 URL: http://issues.apache.org/jira/browse/JAMES-601
>             Project: James
>          Issue Type: Improvement
>          Components: Mailet API, James Core, Matchers/Mailets (bundled), Remote Delivery, Mailet Contributions
>    Affects Versions: 2.3.0rc1
>         Environment: james 2.3.0rc1
>            Reporter: Guillermo Grandes
>         Assigned To: Stefano Bagnara
>             Fix For: Trunk
>
>         Attachments: JAMES-601-Plus.diff, JAMES-601.diff, James-final-20060923.diff, James.java.diff, James.java.diff, JamesChildsLogger.java.diff
>
>
> In order to improve the organization and operation of logs I have thought about this piece of code, without change Mailet API and that does not force to make great changes in the Mailets.
> This code affects :
> http://svn.apache.org/viewvc/james/server/branches/v2.3/src/java/org/apache/james/James.java
> ==============================================
> /**
> * Return the logger for the Mailet API
> *
> * @return the logger for the Mailet API
> */
> private Logger getMailetLogger() {     // it replaces the original method
>     if (mailetLogger == null) {
>         mailetLogger = getLogger().getChildLogger("Mailet");
>     }
>     String p = findParentCaller();
>     return ((p == null) ? mailetLogger : mailetLogger.getChildLogger(p));
> }
> /**
> * Return the Caller Mailet
> *
> * @return the ClassName for the Caller Mailet / Matcher
> */
> private String findParentCaller() {    // it is a new method
>     try {
>         throw new Exception();
>     }
>     catch (Throwable t) {
>         StackTraceElement[] ste = t.getStackTrace();
>         int i;
>         boolean found = false;
>         for (i = 0; i < ste.length; i++) {
>             String cn = ste[i].getClassName();
>             if (cn.startsWith("sun") || cn.startsWith("java") || cn.startsWith("$")) continue; // speed-up
>             if ((cn.equals("org.apache.mailet.GenericMailet")) ||
>                 (cn.equals("org.apache.mailet.GenericMatcher"))) {
>                 continue;
>             }
>             try {
>                 Class c = Class.forName(cn);
>                 if ((org.apache.mailet.GenericMailet.class.isAssignableFrom(c)) ||
>                     (org.apache.mailet.GenericMatcher.class.isAssignableFrom(c))) {
>                     found = true; break;
>                 }
>             }
>             catch(Exception ign) {}
>         }
>         if (!found) return null;
>         try {
>             return ste[i].getClassName().replace("$", ".");
>         }
>         catch (Exception ign) {}
>         return null;
>     }
> }
> ==============================================
> The result of this patch is:
> Original Logs...
> INFO  [James.Mailet] ToRepository: Storing mail Mail1222222222222-0 in file://var/mail/inbound/
> INFO  [James.Mailet] RemoteDelivery: Attempting delivery of Mail1222222222222-0 to host 192.168.1.1 at 192.168.1.1 for addresses [apache.james@localhost]
> INFO  [James.Mailet] BayesianAnalysisFeeder: maxSize: 200000
> Improved Logs...
> INFO  [James.Mailet.org.apache.james.transport.mailets.ToRepository] ToRepository: Storing mail Mail1222222222222-0 in file://var/mail/inbound/
> INFO  [James.Mailet.org.apache.james.transport.mailets.RemoteDelivery] RemoteDelivery: Attempting delivery of Mail1222222222222-0 to host 192.168.1.1 at 192.168.1.1 for addresses [apache.james@localhost]
> INFO  [James.Mailet.org.apache.james.transport.mailets.BayesianAnalysisFeeder] BayesianAnalysisFeeder: maxSize: 200000
> With this you can organize your logs by Mailet / Category in environment.xml :-)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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