1 16 package org.apache.cocoon.util.log; 17 18 import org.apache.avalon.excalibur.logger.factory.StreamTargetFactory; 19 import org.apache.avalon.framework.configuration.Configuration; 20 import org.apache.log.format.Formatter; 21 22 45 public class CocoonStreamTargetFactory 46 extends StreamTargetFactory { 47 48 private static final String CFORMAT = 50 "%7.7{priority} %{time} [%8.8{category}] (%{uri}) %{thread}/%{class:short}: %{message}\\n%{throwable}"; 51 52 private static final String XFORMAT = 54 "priority time category uri thread class message throwable"; 55 56 protected Formatter getFormatter(final Configuration conf) { 57 final String type = conf.getAttribute("type", "unknown"); 58 59 if ("cocoon".equals(type)) { 60 int depth = conf.getAttributeAsInteger( "depth", 0 ); 61 final CocoonLogFormatter formatter = new CocoonLogFormatter( depth ); 62 final String format = conf.getValue(CFORMAT); 63 formatter.setFormat(format); 64 return formatter; 65 } else if ("xml".equals(type)) { 66 final XMLCocoonLogFormatter formatter = new XMLCocoonLogFormatter(); 67 final String format = conf.getValue(XFORMAT); 68 formatter.setTypes(format); 69 return formatter; 70 } 71 72 return super.getFormatter(conf); 74 } 75 } 76 77 | Popular Tags |