---
title: "tomcat下部署了多个项目且都使用log4j"
author: "chensl"
date: "2015-07-24T11:33:47Z"
tags: []
categories: ["Web前端"]
slug: "tomcat-log4j"
draft: false
lastmod: "2015-07-24T11:33:47Z"
id: 2229875
url: "https://chensl.iteye.com/blog/2229875"
---

```
<!--如果不定义webAppRootKey参数，那么webAppRootKey就是缺省的"webapp.root"。但最好设置，以免项目之间的名称冲突。
定义以后，在Web Container启动时将把ROOT的绝对路径写到系统变量里。
然后log4j的配置文件里就可以用${webName.root }来表示Web目录的绝对路径，把log文件存放于webapp中。
此参数用于后面的“Log4jConfigListener”-->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>webName.root</param-value>
</context-param>
```