KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > excalibur > logger > factory > LF5TargetFactory


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14  * implied.
15  *
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */

19 package org.apache.avalon.excalibur.logger.factory;
20
21 import org.apache.avalon.excalibur.logger.LogTargetFactory;
22 import org.apache.avalon.framework.configuration.Configuration;
23 import org.apache.avalon.framework.configuration.ConfigurationException;
24 import org.apache.log.LogTarget;
25 import org.apache.log.output.lf5.LF5LogTarget;
26
27 /**
28  * A factory for the <a HREF="http://jakarta.apache.org/log4j/docs/lf5/features.html">LogFactor5</a>
29  * Swing GUI.
30  * <p>
31  * Configuration :
32  * <pre>
33  * &lt;lf5 id="target-id"&gt;
34  * &lt;NDC-format type="raw|pattern|extended"&gt;pattern to be used&lt;/NDC-format&gt;
35  * &lt;/lf5&gt;
36  * </pre>
37  *
38  * The optional "NDC-pattern" configuration defines the pattern that will be used to
39  * format the log event for display on the "NDC" line in the Swing GUI.
40  *
41  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
42  * @version CVS $Revision: 1.8 $ $Date: 2004/03/10 13:54:50 $
43  */

44
45 public class LF5TargetFactory implements LogTargetFactory
46 {
47     public LogTarget createTarget( final Configuration configuration )
48         throws ConfigurationException
49     {
50         LF5LogTarget result = new LF5LogTarget();
51
52         Configuration child = configuration.getChild( "NDC-pattern", false );
53         if( null != child )
54         {
55             result.setNDCFormatter( new FormatterFactory().createFormatter( child ) );
56         }
57
58         return result;
59     }
60 }
61
Popular Tags