springmvc中配置log4j的問題

2021-08-29 05:41:37 字數 365 閱讀 7492

根據某些網上資料說明,使用

[code]

org.springframework.web.util.log4jconfiglistener

[/code]

進行配置,然而這個設定在tomcat裡面是無效的,而且會出現所有url無效問題,仔細看了下jpetstore中web.xml的說明才發現:

[code]

[/code]

除去這個方式,可以使用如下方式進行配置:

[code]

log4j

org.springframework.web.util.log4jconfigservlet

1[/code]

最後記住把log4j的jar放到lib中

spring mvc中log4j的配置與使用

如果使用spring外掛程式建立乙個spring template project,它會預設帶log4j,只要改下log4j的配置就可以使用了,如果自己建立的project,就要載入下log4f的包了,使用步驟如下 color green b size large 1.pom.xml加入log4j的...

springMVC中快速配置shiro

1.在web.xml檔案中配置shiro的過濾器,以攔截專案內的訪問 shirofilter org.springframework.web.filter.delegatingfilterproxy targetfilterlifecycle true shirofilter 2.在spring 的...

log4j2在SpringMVC中的使用

在看開源druid資料庫連線池時,了解到druid不依賴log元件但會根據當前環境選擇一種合適的log實現,預設順序為log4j log4j2 slf4j common log jdklogging,druid介紹了log4j2在springboot中的使用,發現確實很方便,在springmvc中簡...