DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24063>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24063 Logger Enhancement / Log Iterator,Collection,[] ------- Additional Comments From [EMAIL PROTECTED] 2003-10-24 11:11 ------- Understand... The problem of the 'Collection'.toString() is that the info gets a little to, much confusing, on the log. Specially if there are too many Objects and/or of diferent Classes, for example : import java.util.*; public class Tester { public Tester(){ System.out.println("Confusing log"); logArrayListStd(); System.out.println("More understandable log"); logArrayListEx(); } public void logArrayListEx(){ Collection list = new ArrayList(); for(int i = 0; i < 5 ; i++){ if(i==1 || i==2 || i==4){ list.add( new MyTest2(i+"", ((char)('a'+i)) +"")); }else{ list.add( new MyTest(i+"", ((char)('a'+i))+"")); } } Object []array = list.toArray(); System.out.println("--------- DEBUGING COLLECTION INIT --------- --"); for(int i = 0; i < array.length ; i++){ System.out.println(i+" - ["+array[i].getClass().getName ()+"] -> "+array[i]); } System.out.println("--------- DEBUGING COLLECTION END --------- --"); } public void logArrayListStd(){ Collection list = new ArrayList(); for(int i = 0; i < 5 ; i++){ if(i==1 || i==2 || i==4){ list.add( new MyTest2(i+"", ((char)('a'+i)) +"")); }else{ list.add( new MyTest(i+"", ((char)('a'+i))+"")); } } System.out.println("ArrayList = "+list); } public static void main(String[] args){ Tester tester = new Tester(); } } class MyTest{ String nome; String lixo; public MyTest(String _nome, String _lixo){ nome = _nome; lixo = _lixo; } public String toString(){ return "nome="+nome+",lixo="+lixo; } } class MyTest2 extends MyTest{ public MyTest2(String _nome, String _lixo){ super(_nome, _lixo); } public String toString(){ return "lixo="+lixo+";nome="+nome; } } Placing many times that logging code, it's not a good idea... It could be created a Class with some methods to handle this logging, something like this : public void logCollection(Collection col[, ...] ); But that would be running away from the 'standart' logging and importing some more classes, use more memory with new instances (well it could be used some static methods, or even a singleton), and so on and so on... Regards, Daniel Campelo --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
