[slf4j-dev] [Bug 184] New: Log array contents if only one parameter is specified in log string

bugzilla-daemon at pixie.qos.ch bugzilla-daemon at pixie.qos.ch
Tue May 18 15:50:57 CEST 2010


http://bugzilla.slf4j.org/show_bug.cgi?id=184

           Summary: Log array contents if only one parameter is specified in
                    log string
           Product: SLF4J
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P3
         Component: Core API
        AssignedTo: slf4j-dev at qos.ch
        ReportedBy: dumitru.postoronca at gmail.com


Hello,

When using Java5 var-args which are represented as an array, slf4j logs only
the first item in the array (which is correct as per documentation, just that
it's not very intuitive).

Example:
void getFilteredData(String... filterValues) {
    log.debug("Getting data, filtering using the following settings: {}",
filterValues);
    return dao.doSomething();
}

What happens is that only the first item is logged, insted of all the items
being logged. The current work-around for this is to have the following method
call:
    log.debug(".... {} {}", "", myArray); // note the first empty log parameter

I would suggest enhancing the framework to automatically log the array content
if only ONE {} parameter is specified in the log string. In this case:
    log.debug("... {}", myArray); // logs full array content, not only first
item
    log.debug("... {}={}"); // logs as per current algorithm - first two items

I believe it is safe to assume that people will use the log.debug(array) method
only when they have more than two parameters to show, thus - if only one
parameter is used, it's only reasonable that the FULL content of the passed
object is logged, no matter the type.

Thanks,
Dima


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


More information about the slf4j-dev mailing list