[logback-dev] [JIRA] Commented: (LBGENERAL-49) Logback does not pass turkey test

Ralph Goers (JIRA) noreply-jira at qos.ch
Thu Dec 1 09:44:14 CET 2011


    [ http://jira.qos.ch/browse/LBGENERAL-49?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12320#action_12320 ] 

Ralph Goers commented on LBGENERAL-49:
--------------------------------------

I'm not sure I understand this issue, at least with respect to HTMLLayout. Your test sets the default locale to turkey. You then creates an HTMLLayout and calls the doLayout message which returns a String. However, Logback now requires that Layout's be wrapped with encoders to translate them into byte arrays. You didn't do that so the default locale 

> Logback does not pass turkey test
> ---------------------------------
>
>                 Key: LBGENERAL-49
>                 URL: http://jira.qos.ch/browse/LBGENERAL-49
>             Project: logback-general
>          Issue Type: Bug
>    Affects Versions: 1.0.0
>            Reporter: Sebastian Davids
>            Assignee: Logback dev list
>         Attachments: turkey.patch
>
>
> import java.io.Serializable;
> import java.util.ArrayList;
> import java.util.List;
> public class Bean implements Serializable {
> 	private static final long serialVersionUID = 1957667958813006175L;
> 	private List<String> iceCreams = new ArrayList<String>();
> 	public void addIceCream(String iceCream) {
> 		iceCreams.add(iceCream);
> 	}
> 	@Override
> 	public String toString() {
> 		return iceCreams.toString();
> 	}
> }
> ////
> import java.beans.Introspector;
> import java.util.Locale;
> import org.slf4j.LoggerFactory;
> import ch.qos.logback.classic.Level;
> import ch.qos.logback.classic.Logger;
> import ch.qos.logback.classic.html.HTMLLayout;
> import ch.qos.logback.classic.spi.ILoggingEvent;
> import ch.qos.logback.classic.spi.LoggingEvent;
> import ch.qos.logback.core.ContextBase;
> import ch.qos.logback.core.joran.util.PropertySetter;
> public class Main {
> 	public static void main(String[] args) {
> 		Bean bean = new Bean();
> 		PropertySetter setter = new PropertySetter(bean);
> 		setter.setContext(new ContextBase());
> 		String propertyName = "iceCream";
> 		setter.addBasicProperty(propertyName, "vanilla");
> 		System.out.println(bean);
> 		System.out.println(propertyName.toUpperCase());
> 		Locale.setDefault(new Locale("tr", "", ""));
> 		setter.addBasicProperty(propertyName, "chocolate");
> 		System.out.println(bean);
> 		System.out.println(propertyName.toUpperCase());
> 		System.out.println(Introspector.decapitalize("IceCream"));
> 		System.out.println("I".toLowerCase() + "ceCream");
> 		System.out.println(capitalizeFirstLetter(propertyName));
> 		System.out.println("i".toUpperCase() + "ceCream");
> 		Logger logger = (Logger) LoggerFactory.getLogger("iAmALogger");
> 		Level level = Level.INFO;
> 		ILoggingEvent event = new LoggingEvent("iAmALoggingEvent", logger, level, "i am logging", null, null);
> 		System.out.println(event);
> 		
> 		HTMLLayout layout = new HTMLLayout();
> 		String html = layout.doLayout(event);
> 		System.out.println(html);
> 	}
> 	public static String capitalizeFirstLetter(String name) {
> 		if (name == null || name.length() == 0) {
> 			return name;
> 		}
> 		char chars[] = name.toCharArray();
> 		chars[0] = Character.toUpperCase(chars[0]);
> 		return new String(chars);
> 	}
> }
> @@ Output @@
> [vanilla]
> ICECREAM
> [vanilla]
> İCECREAM
> iceCream
> ıceCream
> IceCream
> İceCream
> [INFO] i am logging
> <tr class="ınfo even">
> </tr>
> @@@@
> http://www.codinghorror.com/blog/2008/03/whats-wrong-with-turkey.html

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

       


More information about the logback-dev mailing list