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 "Guillermo Grandes (JIRA)" <se...@james.apache.org> on 2006/09/15 00:18:56 UTC
[jira] Updated: (JAMES-601) Add Class detail in logs of
James.Mailet (patch)
[ http://issues.apache.org/jira/browse/JAMES-601?page=all ]
Guillermo Grandes updated JAMES-601:
------------------------------------
Attachment: James.java.diff
Here it is the Patch for Trunk v3.0 & Branch v2.3
http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/James.java
http://svn.apache.org/viewvc/james/server/branches/v2.3/src/java/org/apache/james/James.java
> 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
> Attachments: James.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