1 55 package org.apache.log.output; 56 57 import java.io.OutputStream ; 58 import java.io.OutputStreamWriter ; 59 import java.io.Writer ; 60 import org.apache.log.format.Formatter; 61 import org.apache.log.format.PatternFormatter; 62 import org.apache.log.output.io.WriterTarget; 63 64 73 public class DefaultOutputLogTarget 74 extends WriterTarget 75 { 76 private static final String FORMAT = 77 "%7.7{priority} %5.5{time} [%8.8{category}] (%{context}): %{message}\\n%{throwable}"; 78 79 85 protected void initPattern() 86 { 87 } 88 89 public DefaultOutputLogTarget( final Formatter formatter ) 90 { 91 this( new OutputStreamWriter ( System.out ), formatter ); 92 } 93 94 98 public DefaultOutputLogTarget() 99 { 100 this( new OutputStreamWriter ( System.out ) ); 101 } 102 103 108 public DefaultOutputLogTarget( final OutputStream output ) 109 { 110 this( new OutputStreamWriter ( output ) ); 111 } 112 113 118 public DefaultOutputLogTarget( final Writer writer ) 119 { 120 this( writer, new PatternFormatter( FORMAT ) ); 121 } 122 123 public DefaultOutputLogTarget( final Writer writer, final Formatter formatter ) 124 { 125 super( writer, formatter ); 126 initPattern(); 127 } 128 129 138 public void setFormat( final String format ) 139 { 140 ( (PatternFormatter)m_formatter ).setFormat( format ); 141 } 142 } 143 | Popular Tags |