JBoss 7.1 has the log4j module built in. When developing, the project can just include the logging API lib (like log4j) in the project classpath, so that the project compiles. When build, the log4j.jar/log4j.xml/log4j.properties does not need to be packed in the deployment archive (ear, or war). It would be ignored by JBoss 7 even you include them in the archive.
The configuration file for the standalone server is "C:\jboss-as-7.1.1\standalone\configuration\standalone.xml".
To confiure the console output format and the server log file, just edit the section for logging.
<subsystem xmlns="urn:jboss:domain:logging:1.1">
<console-handler name="CONSOLE">
<level name="DEBUG"/>
<formatter>
<pattern-formatter pattern="%d %-5p [%c] %m%n"/>
</formatter>
</console-handler>
<periodic-rotating-file-handler name="FILE">
<formatter>
<pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
<logger category="javax">
<level name="INFO"/>
</logger>
<logger category="javax.enterprise">
<level name="INFO"/>
</logger>
<logger category="javax.faces">
<level name="INFO"/>
</logger>
<logger category="org.jboss">
<level name="INFO"/>
</logger>
<logger category="org.hibernate">
<level name="INFO"/>
</logger>
<logger category="com.sun">
<level name="WARN"/>
</logger>
<logger category="com.arjuna">
<level name="WARN"/>
</logger>
<logger category="org.apache">
<level name="ERROR"/>
</logger>
<logger category="org.apache.tomcat.util.modeler">
<level name="WARN"/>
</logger>
<logger category="sun.rmi">
<level name="WARN"/>
</logger>
<logger category="jacorb">
<level name="WARN"/>
</logger>
<logger category="jacorb.config">
<level name="ERROR"/>
</logger>
<root-logger>
<level name="DEBUG"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
</handlers>
</root-logger>
</subsystem>
In the above example, the two root loggers has logging level set to "DEBUG", in order to remove some bloat output from javax, jboss, apache etc, it sets those categories to logging level "INFO" or even "ERROR". Note that "DEBUG/INFO/ERROR" etc might be case sensitive and lower case not working.
With this configuration, the console output looks like this:
2012-08-22 13:11:57,306 DEBUG [test.jxee.action.AsyncEJBTestBean] testCallAndGetResult... 1345597917306
2012-08-22 13:11:57,321 DEBUG [test.jxee.action.AsyncEJBTestBean] AsyncEJB not finished yet, pause 1 second...
2012-08-22 13:11:57,321 DEBUG [test.jxee.ejb.AsyncEJB] >>> AsyncEJB inited: test.jxee.ejb.AsyncEJB@11e36af
2012-08-22 13:11:57,321 DEBUG [test.jxee.ejb.AsyncEJB] >>> callAndGetResult() started: 1345597917321
2012-08-22 13:11:58,321 DEBUG [test.jxee.action.AsyncEJBTestBean] AsyncEJB not finished yet, pause 1 second...
2012-08-22 13:11:59,321 DEBUG [test.jxee.action.AsyncEJBTestBean] AsyncEJB not finished yet, pause 1 second...
2012-08-22 13:12:00,321 DEBUG [test.jxee.action.AsyncEJBTestBean] AsyncEJB not finished yet, pause 1 second...
2012-08-22 13:12:01,321 DEBUG [test.jxee.action.AsyncEJBTestBean] AsyncEJB not finished yet, pause 1 second...
2012-08-22 13:12:02,321 DEBUG [test.jxee.ejb.AsyncEJB] >>> callAndGetResult() about to send result: 1345597922321
2012-08-22 13:12:02,321 DEBUG [test.jxee.action.AsyncEJBTestBean] testCallAndGetResult...done 1345597922321
Problem:
What if i want to use my own log4j configuration?
This is rare use case, simple answer is why and what the point to use your own logging configuration?
Here's how if you really want to do it. Since JBoss 7.1 already has the log4j module installed, if you want to use your own logging implementation, you need to tell JBoss to unload its log4j. This can be done by providing a conf file called "META-INF/jboss-deployment-structure.xml". It needs to be at a "META-INF" folder, which is located at the root of your deployment archive, ie, ear or war.
Here's an example of this conf file to prevent JBoss 7 from loading it default log4j module:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<!-- to prevent the server from automatically adding some modules-->
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
</deployment>
</jboss-deployment-structure>
分享到:
相关推荐
赠送jar包:jboss-logging-3.3.2.Final.jar; 赠送原API文档:jboss-logging-3.3.2.Final-javadoc.jar; 赠送源代码:jboss-logging-3.3.2.Final-sources.jar; 赠送Maven依赖信息文件:jboss-logging-3.3.2.Final....
赠送jar包:jboss-logging-3.4.3.Final.jar; 赠送原API文档:jboss-logging-3.4.3.Final-javadoc.jar; 赠送源代码:jboss-logging-3.4.3.Final-sources.jar; 赠送Maven依赖信息文件:jboss-logging-3.4.3.Final....
赠送jar包:jboss-logging-3.4.1.Final.jar; 赠送原API文档:jboss-logging-3.4.1.Final-javadoc.jar; 赠送源代码:jboss-logging-3.4.1.Final-sources.jar; 赠送Maven依赖信息文件:jboss-logging-3.4.1.Final....
jboss-logging.jar
赠送jar包:jboss-logging-3.4.2.Final.jar; 赠送原API文档:jboss-logging-3.4.2.Final-javadoc.jar; 赠送源代码:jboss-logging-3.4.2.Final-sources.jar; 赠送Maven依赖信息文件:jboss-logging-3.4.2.Final....
java.lang.NoSuchMethodError: org.jboss.logging.Logger.getMessageLogger(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Object; 错误解决办法
在描述中提到的`jboss-logging.jar`和`jboss-logging-annotations.jar`则是JBoss组织提供的日志服务。`jboss-logging.jar`是一个高效的、可扩展的日志框架,支持多种日志实现,如Log4j、Java.util.logging和SLF4J。...
《JBoss Logging 3.1.0.GA.jar:企业级日志框架解析》 在Java应用程序开发中,日志记录扮演着至关重要的角色,它不仅帮助开发者追踪代码中的问题,还能提供运行时的系统信息和性能分析。JBoss Logging是Red Hat公司...
赠送jar包:jboss-logging-3.3.2.Final.jar; 赠送原API文档:jboss-logging-3.3.2.Final-javadoc.jar; 赠送源代码:jboss-logging-3.3.2.Final-sources.jar; 赠送Maven依赖信息文件:jboss-logging-3.3.2.Final....
赠送jar包:jboss-logging-3.4.3.Final.jar; 赠送原API文档:jboss-logging-3.4.3.Final-javadoc.jar; 赠送源代码:jboss-logging-3.4.3.Final-sources.jar; 赠送Maven依赖信息文件:jboss-logging-3.4.3.Final....
《深入解析jboss-logging-3.3.0.Final.jar在Hibernate框架中的应用》 在Java开发领域,日志管理是不可或缺的一部分,它对于系统的调试、监控以及问题排查至关重要。`jboss-logging`是JBoss社区提供的一款强大且灵活...
Method: In this paper, we carried out an empirical study to explore the logging practice in open source software projects so as to establish a basic understanding on how logging practice is applied ...
标题“hibernate+jboss-logging”涉及到两个关键领域:Hibernate和JBoss Logging,而描述中提到了三个具体的jar文件,它们是实现这些技术的重要组件。让我们深入了解一下这些技术和库。 **Hibernate** 是一个非常...
commons-logging-1.1.0.jboss.jar, commons-logging-1.1.1-javadoc.jar, commons-logging-1.1.1-sources.jar, commons-logging-1.1.1.jar, commons-logging-1.1.jar, commons-logging-1.1.src.jar, commons-logging-...
jboss-logging-3.1.3.GA-sources.jar,可以使用
jboss-logging-3.3.1.Final.jar
《深入解析jboss-logging-3.3.0.Final.jar源码》 在Java世界里,日志处理是至关重要的部分,它帮助开发者记录应用程序的运行情况,调试错误,以及进行性能分析。JBoss Logging是Red Hat开发的一个强大且灵活的日志...
jboss-logging
Java编程中的`java.lang.NoClassDefFoundError: org/jboss/logging/`是一个常见的运行时错误,通常发生在尝试执行一个类时,JVM无法找到在编译时已经存在的类定义。这个错误并不意味着类在编译期间不存在,而是表明...