Java Doc for IsolatedLog4JLogger.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » webapp » logging » 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 » Portal » jetspeed 2.1.3 » org.apache.jetspeed.webapp.logging 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.jetspeed.webapp.logging.IsolatedLog4JLogger

IsolatedLog4JLogger
public class IsolatedLog4JLogger implements Log(Code)
IsolatedLog4JLogger routes all commons-logging logging using Log4J to an ContextClassLoader specific Hierarchy.

For web or application servers providing (and enforcing) commons-logging and Log4J from a shared context (like JBoss), configuring Log4J loggers and appenders from within a (web) application overrides and resets the global Log4J LoggerRepository.

Capturing root logging for logging events from within the web application for example isn't possible using a Log4J propery or xml configuration without routing ALL root logging through the new (web application specific) configuration.

It is possible using the Log4J API directly instead of configuration files, but that requires hardcoded knowledge about how the logging is to be done.

Furthermore, if another application later on reconfigures the root logging again, the current root logging configuration is closed, detached and rerouted to the new configuration.

The same applies of course to common named loggers like capturing springframework logging.

The only way to prevent this stealing of logging configuration is allowing only one log4J configuration for the whole web or application server.
As this has to be done in a web or application server specific manner, setting up Jetspeed for different servers will become rather complex and difficult to automate.

The IsolatedLog4JLogger solves these problems by routing all logging through a statically configured ContextClassLoader isolated LoggerRepository.

Using this class requires a commons-logging.properties file in the WEB-INF/classes folder containing:
 org.apache.commons.logging.Log=org.apache.jetspeed.util.IsolatedLog4JLogger
 

During web application initialization, preferably from a ServletContextListener or a Servlet init method loaded with a load-on-startup value of 0 (zero), a new ContextClassLoader (e.g. web application) specific LoggerRepository as well as the initialization of Log4J should be configured as follows:

 Properties p = new Properties();
 p.load(new FileInputStream(log4jFile));
 // Create a new LoggerRepository
 Hierarchy h = new Hierarchy(new RootCategory(Level.INFO));
 // Configure the LoggerRepository with our own Log4J configuration
 new PropertyConfigurator().doConfigure(p,h);
 // set the LoggerRepository to be used for the current ContextClassLoader
 IsolatedLog4JLogger.setHierarchy(h);
 
Instead of using a PropertyConfigurator a DomConfigurator could be used likewise.

TODO: It might be useful to have this utility class available for usage by Portlet Applications too. Because this class must be included within a web application classpath, a separate jetspeed-tools or jetspeed-utils library will have to be created for it (and possibly other utility classes as well) which then can be put in the web application lib folder.


author:
   Ate Douma
version:
   $Id: IsolatedLog4JLogger.java 531463 2007-04-23 13:35:58Z taylor $



Constructor Summary
public  IsolatedLog4JLogger(String name)
    

Method Summary
public  voiddebug(Object arg0)
    
public  voiddebug(Object arg0, Throwable arg1)
    
public  booleanequals(Object obj)
    
public  voiderror(Object arg0)
    
public  voiderror(Object arg0, Throwable arg1)
    
public  voidfatal(Object arg0)
    
public  voidfatal(Object arg0, Throwable arg1)
    
public  voidinfo(Object arg0)
    
public  voidinfo(Object arg0, Throwable arg1)
    
public  booleanisDebugEnabled()
    
public  booleanisErrorEnabled()
    
public  booleanisFatalEnabled()
    
public  booleanisInfoEnabled()
    
public  booleanisTraceEnabled()
    
public  booleanisWarnEnabled()
    
public static  voidsetHierarchy(Hierarchy hierarchy)
    
public  StringtoString()
    
public  voidtrace(Object arg0)
    
public  voidtrace(Object arg0, Throwable arg1)
    
public  voidwarn(Object arg0)
    
public  voidwarn(Object arg0, Throwable arg1)
    


Constructor Detail
IsolatedLog4JLogger
public IsolatedLog4JLogger(String name)(Code)




Method Detail
debug
public void debug(Object arg0)(Code)



debug
public void debug(Object arg0, Throwable arg1)(Code)



equals
public boolean equals(Object obj)(Code)



error
public void error(Object arg0)(Code)



error
public void error(Object arg0, Throwable arg1)(Code)



fatal
public void fatal(Object arg0)(Code)



fatal
public void fatal(Object arg0, Throwable arg1)(Code)



info
public void info(Object arg0)(Code)



info
public void info(Object arg0, Throwable arg1)(Code)



isDebugEnabled
public boolean isDebugEnabled()(Code)



isErrorEnabled
public boolean isErrorEnabled()(Code)



isFatalEnabled
public boolean isFatalEnabled()(Code)



isInfoEnabled
public boolean isInfoEnabled()(Code)



isTraceEnabled
public boolean isTraceEnabled()(Code)



isWarnEnabled
public boolean isWarnEnabled()(Code)



setHierarchy
public static void setHierarchy(Hierarchy hierarchy)(Code)



toString
public String toString()(Code)



trace
public void trace(Object arg0)(Code)



trace
public void trace(Object arg0, Throwable arg1)(Code)



warn
public void warn(Object arg0)(Code)



warn
public void warn(Object arg0, Throwable arg1)(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.