You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by bu...@apache.org on 2006/01/04 18:58:55 UTC

DO NOT REPLY [Bug 38125] New: - add Throwable to message pattern log methods

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38125>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38125

           Summary: add Throwable to message pattern log methods
           Product: Log4j
           Version: 1.3alpha
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P5
         Component: Other
        AssignedTo: log4j-dev@logging.apache.org
        ReportedBy: michael.newcomb@gdc4s.com


Current message pattern log methods are of the form:

debug(String message, Object arg1);
debug(String message, Object arg1, Object arg2);

Please add (for info/warn/error/fatal/trace as well):

debug(String message, Object arg1, Throwable t);
debug(String message, Object arg1, Object arg2, Throwable t);

Thanks,
Michael

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 38125] - add Throwable to message pattern log methods

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38125>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38125





------- Additional Comments From carnold@apache.org  2006-01-04 20:01 -------
There are a couple of reasons that I'm not in favor of these changes:

1. I have a personal dislike of the MessageFormatter work-alike methods being on Logger to begin 
with.  I think they actually should be in a helper class which would allow the user to select which 
formatter they use (MessageFormatter or the JDK 1.5 formatter) and should be the actual JDK 
implementation and not a log4j subset of the MessageFormatter.

2. The motivation for the debug methods is to avoid the cost of formatting the message if the debug 
messages are being suppressed.  However, info and higher messages are generally enabled, so their is 
no significant optimization savings for short-cutting the formatter.  In these cases, use:

logger.warn(new MessageFormatter("foo {}").format(someObj))

3. Since throwing and catching an exception should are expensive, should be rare, and should result in 
a high level, the potential for optimization by deferring formatting again should be minimal.  In these 
cases, use:

logger.warn(new MessageFormatter("foo {}").format(someObj), t);

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 38125] - add Throwable to message pattern log methods

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38125>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38125





------- Additional Comments From michael.newcomb@gdc4s.com  2006-01-04 20:48 -------
How about:

public void debug(String messagePattern, Object[] args) {
  if (repository.isDisabled(Level.DEBUG_INT)) {
    return;
  }
  if (Level.DEBUG.isGreaterOrEqual(this.getEffectiveLevel())) {

    // add format(String, Object[] args) to MessageFormatter
    //
    messagePattern = MessageFormatter.format(messagePattern, args);

    // get last item in argument list
    //
    Object o = args != null && args.length > 0 ? args[args.length - 1] : null;

    forcedLog(FQCN, Level.DEBUG, messagePattern,
              o instanceof Throwable ? (Throwable) o : null);
  }
}

And for JDK 1.5:
public void debug(String messagePattern, Object... args) {
  ...
}


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 38125] - add Throwable to message pattern log methods

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38125>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38125


ceki@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED




------- Additional Comments From ceki@apache.org  2006-01-04 20:19 -------
Notwithsanding Curt's personal dislike for parametrized printing
methods, they are quite helpful in many situations.  It has been a
popular feature of the SLF4J API.  In the absence of an alternative, I
would like to see these methods added for trace, info, warn, error and
fatal.  However, as Curt points out, it is not practical to add them
for variants taking a Throwable. (Otherwise, the number of methods to
be added increases by 10.)


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 38125] - add Throwable to message pattern log methods

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38125>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38125





------- Additional Comments From carnold@apache.org  2006-01-04 23:09 -------
The Object[] or Object... forms were not desirable on the debug level since they still incur an array creation  
cost in the typical case of debug not being enabled.  For the info and higher levels, they may be tolerable 
since they would not be called nearly as frequently and those levels are commonly enabled.

I don't have a problem with parameterized messages, I think it is much cleaner if they are on a different 
class and not Logger which would allow the user to choose which formatter to be used (MessageFormat or 
the JDK 1.5's java.util.Formatter) and may allow some better options supporting JDK 1.5 varargs.  I think 
the right time to discuss the issue is in the log4j 1.3 API review which would follow the current 
compatibility push.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 38125] - add Throwable to message pattern log methods

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38125>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38125


carnold@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED




------- Additional Comments From carnold@apache.org  2007-08-22 18:59 -------
Addressed in LogMF and LogSF in extras companion.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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