On Wednesday 30 January 2002 06:58 am, Patrick Hess wrote:
> I'm playing with phoenix and SAR files and I find it uncomfortable
> to check the logfiles for errors & exception. I'm sure there is
> a way to log all the stuff to the console - but where? ;) Can
> anybody point my nose to the right place to search for this information?
Write your own LogTargetFactory. I've attached my ScreenTargetFactory that
you can use as a starting point. You'll have to remove a few lines in
getFormatter() that reference a custom Formatter.
This will only assist you in dumping out your SAR's logfiles to System.out.
The logfile that phoenix generates is still output to disk only (but the only
exceptions I find in there are failures of my SAR to init/start successfully).
-pete
--
peter royal -> [EMAIL PROTECTED]
/*
* User: proyal
* Date: Sep 25, 2001
* Time: 11:48:43 AM
*/
package com.pace2020.appbox.util.log;
import org.apache.avalon.excalibur.logger.factory.AbstractTargetFactory;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.log.LogTarget;
import org.apache.log.format.ExtendedPatternFormatter;
import org.apache.log.format.Formatter;
import org.apache.log.output.io.StreamTarget;
public class ScreenTargetFactory extends AbstractTargetFactory
{
public static final String FORMAT =
"%8.8{priority} %-12.12{time} [%8.8{category}] (%{thread}) %20.20{class:short}: %{message}\\n%{throwable}";
public LogTarget createTarget(Configuration configuration)
throws ConfigurationException
{
return new StreamTarget(System.out, getFormatter(configuration.getChild("format")));
}
protected Formatter getFormatter(final Configuration conf)
{
final String type = conf.getAttribute("type", "unknown");
final String format = conf.getValue(FORMAT);
if ("appbox".equals(type)) {
return new AppboxLogFormatter(format);
} else if ("extended".equals(type)) {
return new ExtendedPatternFormatter(format);
} else {
return new AppboxLogFormatter(format);
}
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>