Java Doc for Log4jWebConfigurer.java in  » J2EE » spring-framework-2.0.6 » org » springframework » web » util » 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 » J2EE » spring framework 2.0.6 » org.springframework.web.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.springframework.web.util.Log4jWebConfigurer

Log4jWebConfigurer
abstract public class Log4jWebConfigurer (Code)
Convenience class that performs custom Log4J initialization for web environments, allowing for log file paths within the web application, with the option to perform automatic refresh checks (for runtime changes in logging configuration).

WARNING: Assumes an expanded WAR file, both for loading the configuration file and for writing the log files. If you want to keep your WAR unexpanded or don't need application-specific log files within the WAR directory, don't use Log4J setup within the application (thus, don't use Log4jConfigListener or Log4jConfigServlet). Instead, use a global, VM-wide Log4J setup (for example, in JBoss) or JDK 1.4's java.util.logging (which is global too).

Supports three init parameters at the servlet context level (that is, context-param entries in web.xml):

  • "log4jConfigLocation":
    Location of the Log4J config file; either a "classpath:" location (e.g. "classpath:myLog4j.properties"), an absolute file URL (e.g. "file:C:/log4j.properties), or a plain path relative to the web application root directory (e.g. "/WEB-INF/log4j.properties"). If not specified, default Log4J initialization will apply ("log4j.properties" in the class path; see Log4J documentation for details).
  • "log4jRefreshInterval":
    Interval between config file refresh checks, in milliseconds. If not specified, no refresh checks will happen, which avoids starting Log4J's watchdog thread.
  • "log4jExposeWebAppRoot":
    Whether the web app root system property should be exposed, allowing for log file paths relative to the web application root directory. Default is "true"; specify "false" to suppress expose of the web app root system property. See below for details on how to use this system property in log file locations.

Note: initLogging should be called before any other Spring activity (when using Log4J), for proper initialization before any Spring logging attempts.

Log4J's watchdog thread will asynchronously check whether the timestamp of the config file has changed, using the given interval between checks. A refresh interval of 1000 milliseconds (one second), which allows to do on-demand log level changes with immediate effect, is not unfeasible.

WARNING: Log4J's watchdog thread does not terminate until VM shutdown; in particular, it does not terminate on LogManager shutdown. Therefore, it is recommended to not use config file refreshing in a production J2EE environment; the watchdog thread would not stop on application shutdown there.

By default, this configurer automatically sets the web app root system property, for "${key}" substitutions within log file locations in the Log4J config file, allowing for log file paths relative to the web application root directory. The default system property key is "webapp.root", to be used in a Log4J config file like as follows:

log4j.appender.myfile.File=${webapp.root}/WEB-INF/demo.log

Alternatively, specify a unique context-param "webAppRootKey" per web application. For example, with "webAppRootKey = "demo.root":

log4j.appender.myfile.File=${demo.root}/WEB-INF/demo.log

WARNING: Some containers (like Tomcat) do not keep system properties separate per web app. You have to use unique "webAppRootKey" context-params per web app then, to avoid clashes. Other containers like Resin do isolate each web app's system properties: Here you can use the default key (i.e. no "webAppRootKey" context-param at all) without worrying.
author:
   Juergen Hoeller
since:
   12.08.2003
See Also:   org.springframework.util.Log4jConfigurer
See Also:   Log4jConfigListener
See Also:   Log4jConfigServlet



Field Summary
final public static  StringCONFIG_LOCATION_PARAM
    
final public static  StringEXPOSE_WEB_APP_ROOT_PARAM
    
final public static  StringREFRESH_INTERVAL_PARAM
    


Method Summary
public static  voidinitLogging(ServletContext servletContext)
     Initialize Log4J, including setting the web app root system property.
public static  voidshutdownLogging(ServletContext servletContext)
     Shut down Log4J, properly releasing all file locks and resetting the web app root system property.

Field Detail
CONFIG_LOCATION_PARAM
final public static String CONFIG_LOCATION_PARAM(Code)
Parameter specifying the location of the Log4J config file



EXPOSE_WEB_APP_ROOT_PARAM
final public static String EXPOSE_WEB_APP_ROOT_PARAM(Code)
Parameter specifying whether to expose the web app root system property



REFRESH_INTERVAL_PARAM
final public static String REFRESH_INTERVAL_PARAM(Code)
Parameter specifying the refresh interval for checking the Log4J config file





Method Detail
initLogging
public static void initLogging(ServletContext servletContext)(Code)
Initialize Log4J, including setting the web app root system property.
Parameters:
  servletContext - the current ServletContext
See Also:   WebUtils.setWebAppRootSystemProperty



shutdownLogging
public static void shutdownLogging(ServletContext servletContext)(Code)
Shut down Log4J, properly releasing all file locks and resetting the web app root system property.
Parameters:
  servletContext - the current ServletContext
See Also:   WebUtils.removeWebAppRootSystemProperty



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.