2011-04-01 28 views
1

我得到以下,但log4j的在Java EE項目log4j的JSP進口

09:09:56,785 ERROR [0]] Exception Processing ErrorPage[errorCode=404, location=/pages/sorry3.jsp] 
org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 1 in the generated java file 
The type org.apache.log4j.Logger cannot be resolved. It is indirectly referenced from required .class files 

An error occurred at line: 10 in the generated java file 
The import org.apache.log4j.Logger cannot be resolved 

An error occurred at line: 54 in the jsp file: /pages/sorry3.jsp 
Logger cannot be resolved 

53:  
54:  Logger.getLogger("com.mysite.myapp.jsps.sorry3").error(
55:   "Page Not Found: " + pageContext.getErrorData().getRequestURI()); 
56: %> 
57: 

的java文件工作正常,如果任何人都可以在正確的方向指向我,那將是巨大的。

+0

進口在頁面太的頂部:<%@頁面進口=「org.apache.log4j.Logger」%> – 2011-04-01 08:19:05

回答

4

聽起來好像你在你的類路徑中沒有log4.jar/log4j.properties。

將它添加到您的CLASSPATH中。

通常,log4j.properties應該在WEB-INF/classes

它應該工作

+0

怎麼能爲普通的Java文件的工作呢? – 2011-04-01 08:37:07

+0

什麼是log4j.properties在您的項目中的位置 – 2011-04-01 09:04:19

+0

我正在使用geronimo,它來打包。我已經成功地使用它並按照我想要的方式進行記錄。要回答您的問題,請在{geronimo_home} /var/log/server-log4j.properties – 2011-04-01 09:11:19