Source Code Cross Referenced for CocoonTargetFactory.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » util » log » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » apache lenya 2.0 » org.apache.cocoon.util.log 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.cocoon.util.log;
018:
019:        import org.apache.avalon.excalibur.logger.factory.FileTargetFactory;
020:        import org.apache.avalon.framework.configuration.Configuration;
021:        import org.apache.log.format.Formatter;
022:
023:        /**
024:         * CocoonTargetFactory class.
025:         *
026:         * This factory is able to create different LogTargets specific to Cocoon
027:         * according to the following configuration syntax:
028:         *
029:         * <pre>
030:         * &lt;file id="foo"&gt;
031:         *  &lt;filename&gt;${context-key}/real-name/...&lt;/filename&gt;
032:         *  &lt;format type="raw|pattern|extended|xml|cocoon"&gt;pattern to be used if needed&lt;/format&gt;
033:         *  &lt;append&gt;true|false&lt;/append&gt;
034:         *  &lt;rotation type="revolving|unique" init="5" max="10"&gt;
035:         *   &lt;or&gt;
036:         *    &lt;size&gt;10000000&lt;/size&gt;
037:         *    &lt;time&gt;24:00:00&lt;/time&gt;
038:         *    &lt;time&gt;12:00:00&lt;/time&gt;
039:         *   &lt;/or&gt;
040:         *  &lt;/rotate&gt;
041:         * &lt;/file&gt;
042:         * </pre>
043:         *
044:         * <p>Some explanations about the Elements used in the configuration:</p>
045:         * <dl>
046:         *  <dt>&lt;filename&gt;</dt>
047:         *  <dd>
048:         *   This denotes the name of the file to log to. It can be constructed
049:         *   out of entries in the passed Context object as ${context-key}.
050:         *   This element is required.
051:         *  </dd>
052:         *  <dt>&lt;format&gt;</dt>
053:         *  <dd>
054:         *   The type attribute of the pattern element denotes the type of
055:         *   Formatter to be used and according to it the pattern to use for.
056:         *   This elements defaults to:
057:         *   <p>
058:         *    %7.7{priority} %{time}   [%8.8{category}] (%{uri}) %{thread}/%{class:short}: %{message}\\n%{throwable}
059:         *   </p>
060:         *  </dd>
061:         *  <dt>&lt;append&gt;<dt>
062:         *  <dd>
063:         *   If the log file should be deleted every time the logger is creates
064:         *   (normally at the start of the applcation) or not and thus the log
065:         *   entries will be appended. This elements defaults to false.
066:         *  </dd>
067:         *  <dt>&lt;rotation&gt;</dt>
068:         *  <dd>
069:         *   This is an optional element.
070:         *   The type attribute determines which FileStrategy to user
071:         *   (revolving=RevolvingFileStrategy, unique=UniqueFileStrategy).
072:         *   The required init and max attribute are used to determine the initial and
073:         *   maximum rotation to use on a type="revolving" attribute.
074:         *  </dd>
075:         *  <dt>&lt;or&gt;</dt>
076:         *  <dd>uses the OrRotateStrategy to combine the children</dd>
077:         *  <dt>&lt;size&gt;</dt>
078:         *  <dd>
079:         *   The number of bytes if no suffix used or kilo bytes (1024) if suffixed with
080:         *   'k' or mega bytes (1024k) if suffixed with 'm' when a file rotation should
081:         *   occur. It doesn't make sense to specify more than one.
082:         *  </dd>
083:         *  <dt>&lt;time&gt;</dt>
084:         *  <dd>
085:         *   The time as HH:MM:SS when a rotation should occur. If you like to rotate
086:         *   a logfile more than once a day put an &lt;or&gt; element immediately after the
087:         *   &lt;rotation&gt; element and specify the times (and one size, too) inside the
088:         *   &lt;or&gt; element.
089:         *  </dd>
090:         * </dl>
091:         *
092:         * @deprecated This class will be removed in 2.2
093:         * @author <a href="mailto:giacomo@apache.org">Giacomo Pati</a>
094:         * @version CVS $Id: CocoonTargetFactory.java 433543 2006-08-22 06:22:54Z crossley $
095:         */
096:        public class CocoonTargetFactory extends FileTargetFactory {
097:            //Format of default Cocoon formatter
098:            private static final String CFORMAT = "%7.7{priority} %{time}   [%8.8{category}] (%{uri}) %{thread}/%{class:short}: %{message}\\n%{throwable}";
099:
100:            //Format of default Cocoon XML formatter
101:            private static final String XFORMAT = "priority time category uri thread class message throwable";
102:
103:            protected Formatter getFormatter(final Configuration conf) {
104:                final String type = conf.getAttribute("type", "unknown");
105:
106:                if ("cocoon".equals(type)) {
107:                    int depth = conf.getAttributeAsInteger("depth", 0);
108:                    final CocoonLogFormatter formatter = new CocoonLogFormatter(
109:                            depth);
110:                    final String format = conf.getValue(CFORMAT);
111:                    formatter.setFormat(format);
112:                    return formatter;
113:                } else if ("xml".equals(type)) {
114:                    final XMLCocoonLogFormatter formatter = new XMLCocoonLogFormatter();
115:                    final String format = conf.getValue(XFORMAT);
116:                    formatter.setTypes(format);
117:                    return formatter;
118:                }
119:                // default formatter
120:                return super.getFormatter(conf);
121:            }
122:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.