我的LOG4J怎么不输出日志啊

时间:2022-11-05 21:55:44
我的配置文件logConfig.properties
log4j.rootLogger=INFO,stdout,logfile

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n

log4j.appender.logfile=org.apache.log4j.RollingFileAppender
log4j.appender.logfile.File=${myApp.root}/WEB-INF/logs/ideashopx.log
log4j.appender.logfile.MaxFileSize=1024KB
# Keep three backup files.
log4j.appender.logfile.MaxBackupIndex=3
# Pattern to output: date priority [category] - message
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n


web.xml的内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_88" version="2.4" 
xmlns="http://java.sun.com/xml/ns/j2ee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>JEZZ Struts 2.0 Project</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
    <!-- 防止乱码过滤 -->
    <filter>   
    <filter-name>encoding</filter-name>     
         <filter-class>EnterpriseSite.EncodingFilter</filter-class>     
          <init-param>   
                    <param-name>encoding</param-name>   
                    <param-value>UTF-8</param-value>   
          </init-param>   
    </filter>                    
    <filter-mapping>     
                <filter-name>encoding</filter-name>     
                <url-pattern>/*</url-pattern>       
    </filter-mapping>
     
    <!-- 跟ONGL语言和request和response有关 -->
    <filter>
        <filter-name>struts-cleanup</filter-name>
        <filter-class>
            org.apache.struts2.dispatcher.ActionContextCleanUp
        </filter-class>
    </filter>    
    <filter-mapping>
        <filter-name>struts-cleanup</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <!-- 过滤Struts2的action -->
    <filter>
    <filter-name>struts2</filter-name>        
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <!-- 配置proxool连接池 -->
<servlet>
  <servlet-name>ServletConfigurator</servlet-name>
  <servlet-class>org.logicalcobwebs.proxool.configuration.ServletConfigurator</servlet-class>
  <init-param>
    <param-name>xmlFile</param-name>
    <param-value>WEB-INF/db.xml</param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet>
    <servlet-name>Admin</servlet-name>
    <servlet-class>org.logicalcobwebs.proxool.admin.servlet.AdminServlet</servlet-class>
 </servlet>
 <servlet-mapping>
    <servlet-name>Admin</servlet-name>
    <url-pattern>/admin</url-pattern>
 </servlet-mapping>
    <!-- 配合SPRING配置log4j -->
    <context-param>
     <param-name>webAppRootKey</param-name>
     <param-value>myApp.root</param-value>
    </context-param>
    <context-param>
     <param-name>log4jConfigLocation</param-name>
     <param-value>/WEB-INF/classes/logConfig.properties</param-value>
    </context-param>
    <!--Spring默认刷新Log4j配置文件的间隔,单位为millisecond-->
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>60000</param-value>
</context-param>

<!--Spring log4j Config loader-->
<listener>
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener>

<!-- 配置SPRING -->
   <listener> 
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
   </listener> 
   
</web-app>


我的开发环境是eclipse3.2 我是直接log4j放到开发环境下去,没有在系统那个classpath加上LOG4J的路径,我估计这个么影响吧!
启动TOMCAT也不报错,我那个地方出问题了!大家帮我看下

8 个解决方案

#1


该回复于2015-05-26 13:23:37被管理员删除

#2


sping框架的设置了没啊?

#3


### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %m%n

### direct messages to file hibernate.log ###
#log4j.appender.file=org.apache.log4j.FileAppender
#log4j.appender.file.File=hibernate.log
#log4j.appender.file.layout=org.apache.log4j.PatternLayout
#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### set log levels - for more verbose logging change 'info' to 'debug' ###

#log4j.rootLogger=stdout
log4j.rootLogger=warn,stdout


#log4j.logger.org.hibernate=info
log4j.logger.org.hibernate=debug

### log HQL query parser activity
#log4j.logger.org.hibernate.hql.ast.AST=debug

### log just the SQL
#log4j.logger.org.hibernate.SQL=debug

### log JDBC bind parameters ###
log4j.logger.org.hibernate.type=info
#log4j.logger.org.hibernate.type=debug

### log schema export/update ###
log4j.logger.org.hibernate.tool.hbm2ddl=debug

### log HQL parse trees
#log4j.logger.org.hibernate.hql=debug

### log cache activity ###
#log4j.logger.org.hibernate.cache=debug

### log transaction activity
#log4j.logger.org.hibernate.transaction=debug

### log JDBC resource acquisition
#log4j.logger.org.hibernate.jdbc=debug

### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace




上面是LOg4j文件放在src根目录下

并且导入log4j对应的包

#4


引用 2 楼 tcl_79527922 的回复:
sping框架的设置了没啊?


spring还有设置什么?

#5


Spring没有设置的.  

#6


把文件名命名为log4j.properties,放入src目录下就好了,再倒入log4j.jar就好了不需要什么特殊的配置

#7


在ECLIPSE不能放到SRC目录里面去,直接找到工程文件所在地方直接放在SRC里面?

#8


学习了,,

#1


该回复于2015-05-26 13:23:37被管理员删除

#2


sping框架的设置了没啊?

#3


### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %m%n

### direct messages to file hibernate.log ###
#log4j.appender.file=org.apache.log4j.FileAppender
#log4j.appender.file.File=hibernate.log
#log4j.appender.file.layout=org.apache.log4j.PatternLayout
#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### set log levels - for more verbose logging change 'info' to 'debug' ###

#log4j.rootLogger=stdout
log4j.rootLogger=warn,stdout


#log4j.logger.org.hibernate=info
log4j.logger.org.hibernate=debug

### log HQL query parser activity
#log4j.logger.org.hibernate.hql.ast.AST=debug

### log just the SQL
#log4j.logger.org.hibernate.SQL=debug

### log JDBC bind parameters ###
log4j.logger.org.hibernate.type=info
#log4j.logger.org.hibernate.type=debug

### log schema export/update ###
log4j.logger.org.hibernate.tool.hbm2ddl=debug

### log HQL parse trees
#log4j.logger.org.hibernate.hql=debug

### log cache activity ###
#log4j.logger.org.hibernate.cache=debug

### log transaction activity
#log4j.logger.org.hibernate.transaction=debug

### log JDBC resource acquisition
#log4j.logger.org.hibernate.jdbc=debug

### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace




上面是LOg4j文件放在src根目录下

并且导入log4j对应的包

#4


引用 2 楼 tcl_79527922 的回复:
sping框架的设置了没啊?


spring还有设置什么?

#5


Spring没有设置的.  

#6


把文件名命名为log4j.properties,放入src目录下就好了,再倒入log4j.jar就好了不需要什么特殊的配置

#7


在ECLIPSE不能放到SRC目录里面去,直接找到工程文件所在地方直接放在SRC里面?

#8


学习了,,