|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectch.qos.logback.ext.spring.web.WebLogbackConfigurer
public class WebLogbackConfigurer
Convenience class that performs custom Logback initialization for web environments, allowing for log file paths within the web application.
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 Logback setup within the application (thus, don't use LogbackConfigListener or LogbackConfigServlet). Instead, use a global, VM-wide Logback setup (for example, in JBoss) or JDK 1.4'sjava.util.logging
(which is global too).
Supports two init parameters at the servlet context level (that is,
context-param entries in web.xml):
initLogging
should be called before any other Spring activity
(when using Logback), for proper initialization before any Spring logging attempts.
By default, this configurer automatically sets the web app root system property,
for "${key}" substitutions within log file locations in the Logback 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 Logback config
file like as follows:
%-4relative [%thread] %-5level %class - %msg%n
${webapp.root}/WEB-INF/demo.log
Alternatively, specify a unique context-param "webAppRootKey" per web application.
For example, with "webAppRootKey = "demo.root":
%-4relative [%thread] %-5level %class - %msg%n
${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.
Log4jConfigurer
,
Log4jConfigListener
Field Summary | |
---|---|
static String |
CONFIG_LOCATION_PARAM
Parameter specifying the location of the logback config file |
static String |
EXPOSE_WEB_APP_ROOT_PARAM
Parameter specifying whether to expose the web app root system property |
Method Summary | |
---|---|
static void |
initLogging(javax.servlet.ServletContext servletContext)
Initialize Logback, including setting the web app root system property. |
static void |
shutdownLogging(javax.servlet.ServletContext servletContext)
Shut down Logback, properly releasing all file locks and resetting the web app root system property. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String CONFIG_LOCATION_PARAM
public static final String EXPOSE_WEB_APP_ROOT_PARAM
Method Detail |
---|
public static void initLogging(javax.servlet.ServletContext servletContext)
servletContext
- the current ServletContextWebUtils.setWebAppRootSystemProperty(javax.servlet.ServletContext)
public static void shutdownLogging(javax.servlet.ServletContext servletContext)
servletContext
- the current ServletContextWebUtils.removeWebAppRootSystemProperty(javax.servlet.ServletContext)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |