• springMVC项目在jboss7中配置应用自己的log4j--转载


    原文地址:http://www.xuebuyuan.com/1954635.html

    Jboss7默认采用容器自己的log4j module,应用自己配置的log4j不起作用,需要应用做一些设置:

    以springMVC项目为例:

    1> 在WEB-INF下新建文件jboss-deployment-structure.xml,内容如下:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <jboss-deployment-structure>
    
       <deployment>
    
         <exclusions>
    
           <module name="org.apache.log4j" />
    
         </exclusions>
    
       </deployment>
    
    </jboss-deployment-structure> 

    2> 在web.xml里配置

    <context-param>
    		<param-name>log4jConfigLocation</param-name>
    		<param-value>/WEB-INF/log4j.properties</param-value>
    </context-param>
    <listener>
    		<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>

    3> 在WEB-INF下新建log4j.properties

    # For JBoss: Avoid to setup Log4J outside $JBOSS_HOME/server/default/deploy/log4j.xml!
    # For all other servers: Comment out the Log4J listener in web.xml to activate Log4J.
    log4j.rootLogger=INFO,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=${jboss.server.log.dir}/YOURAPP.log
    log4j.appender.logfile.MaxFileSize=512KB
    # 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
    

    4> pom添加依赖

    <dependency> 
           		<groupId>log4j</groupId> 
          		 <artifactId>log4j</artifactId> 
           		<version>1.2.17</version> 
    </dependency>
  • 相关阅读:
    什么是微服务架构!
    Redis使用总结 (序列三)
    redis centos linux操作系统安装及集群使用(序列二)
    Python操作Redis缓存数据库
    高并发系统的限流实现方式
    如何服务器的操作系统中的型号
    B8 Concurrent JDK中的乐观锁与原子类
    B7. Concurrent 锁的分类
    B6. Concurrent 内存模型与线程
    B5. Concurrent JVM 锁优化
  • 原文地址:https://www.cnblogs.com/davidwang456/p/4314313.html
Copyright © 2020-2023  润新知