1 16 package org.apache.cocoon.util.log; 17 18 import org.apache.avalon.excalibur.logger.factory.FileTargetFactory; 19 import org.apache.avalon.framework.configuration.Configuration; 20 import org.apache.log.format.Formatter; 21 22 94 public class CocoonTargetFactory 95 extends FileTargetFactory 96 { 97 private static final String CFORMAT = 99 "%7.7{priority} %{time} [%8.8{category}] (%{uri}) %{thread}/%{class:short}: %{message}\\n%{throwable}"; 100 101 private static final String XFORMAT = 103 "priority time category uri thread class message throwable"; 104 105 protected Formatter getFormatter(final Configuration conf) { 106 final String type = conf.getAttribute("type", "unknown"); 107 108 if ("cocoon".equals(type)) { 109 int depth = conf.getAttributeAsInteger( "depth", 0 ); 110 final CocoonLogFormatter formatter = new CocoonLogFormatter( depth ); 111 final String format = conf.getValue(CFORMAT); 112 formatter.setFormat(format); 113 return formatter; 114 } else if ("xml".equals(type)) { 115 final XMLCocoonLogFormatter formatter = new XMLCocoonLogFormatter(); 116 final String format = conf.getValue(XFORMAT); 117 formatter.setTypes(format); 118 return formatter; 119 } 120 return super.getFormatter(conf); 122 } 123 } 124 125 | Popular Tags |