1 Reply Latest reply on Dec 13, 2013 9:02 AM by Wolf-Dieter Fink

    Per Deployement Logging in Jboss AS 6.1.0

    Vinaya T Newbie

      Hi,

       

      I have multiple applications deployed on one instance on Jboss (multiple wars in /server/hhhh/deploy)

      I would like to have different log files for each application.

      I tried following couple of links posted in this forum, but, they don't work.

      I have removed the Jboss-logging.xml from /server/hhhh/deployu directory and put in under WEB-INF directory.

      First application works fine, but when I deploy the second application and restart the server, I am getting

       

      "error due to the following reason(s): java.lang.IllegalStateException: Logging:LOGGER:system:org.apache is already installed."

      my jboss-logging.xml in WEB_INF directory  is as below

       

       

      <?xml version="1.0" encoding="UTF-8"?>

       

      <!-- ===================================================================== -->

       

      <!-- -->

       

      <!-- Logging System Configuration -->

       

      <!-- -->

       

      <!-- ===================================================================== -->

       

      <logging xmlns="urn:jboss:logging:6.0" xmlns:b="urn:jboss:bean-deployer:2.0" >

       

      <!-- ================================= -->

       

      <!-- Preserve messages in a local file -->

       

      <!-- ================================= -->

       

      <!-- A time/date based rolling handler -->

       

      <periodic-rotating-file-handler

       

      file-name="${jboss.server.log.dir}/server1.log"

       

      name="FILE"

       

      autoflush="true"

       

      append="true"

       

      suffix=".yyyy-MM-dd"

       

      > <!-- To roll over at the top of each hour, use ".yyyy-MM-dd-HH" instead -->

       

       

       

      <error-manager>

       

      <only-once/>

       

      </error-manager>

       

      <formatter>

       

      <!-- To revert back to simple stack traces without JAR versions, change "%E" to "%e" below. -->

       

      <!-- Uncomment this to get the class name in the log as well as the category

       

      <pattern-formatter pattern="%d %-5p [%c] %C{1} (%t) %s%E%n"/>

       

      -->

       

      <!-- Uncomment this to log without the class name in the log -->

       

      <pattern-formatter pattern="%d [%X{principal},%X{sessionId},%X{RemoteAddress}] %-5p [%c] %m%n"/>

       

      </formatter>

       

      </periodic-rotating-file-handler>

       

      <periodic-rotating-file-handler

       

      file-name="${jboss.server.log.dir}/YCable.log"

       

      name="DBFILE"

       

      autoflush="true"

       

      append="true"

       

      suffix=".yyyy-MM-dd"

       

      > <!-- To roll over at the top of each hour, use ".yyyy-MM-dd-HH" instead -->

       

       

       

      <error-manager>

       

      <only-once/>

       

      </error-manager>

       

      <formatter>

       

      <!-- To revert back to simple stack traces without JAR versions, change "%E" to "%e" below. -->

       

      <!-- Uncomment this to get the class name in the log as well as the category

       

      <pattern-formatter pattern="%d %-5p [%c] %C{1} (%t) %s%E%n"/>

       

      -->

       

      <!-- Uncomment this to log without the class name in the log -->

       

      <pattern-formatter pattern="%d [%X{principal},%X{sessionId},%X{RemoteAddress}] %-5p [%c] %m%n"/>

       

      </formatter>

       

      </periodic-rotating-file-handler>

       

      <!-- A size based file rolling appender

       

      <size-rotating-file-handler

       

      file-name="${jboss.server.log.dir}/server.log"

       

      name="FILE"

       

      autoflush="true"

       

      append="true"

       

      rotate-size="500k"

       

      max-backup-index="5">

       

      <error-manager>

       

      <only-once/>

       

      </error-manager>

       

      <formatter>

       

      <pattern-formatter pattern="%d %-5p [%c] (%t) %m%n"/>

       

      </formatter>

       

      </size-rotating-file-handler>

       

      -->

       

      <!-- ============================== -->

       

      <!-- Append messages to the console -->

       

      <!-- ============================== -->

       

       

       

      <!-- ====================== -->

       

      <!-- More Appender examples -->

       

      <!-- ====================== -->

       

      <!-- Buffer events and log them asynchronously

       

      <async-handler name="ASYNC">

       

      <error-manager>

       

      <only-once/>

       

      </error-manager>

       

      <sub-handlers>

       

      <handler-ref name="FILE"/>

       

      <handler-ref name="CONSOLE"/>

       

      <handler-ref name="SMTP"/>

       

      </sub-handlers>

       

      </async-handler>

       

      -->

       

      <!-- EMail events to an administrator

       

      <log4j-appender name="SMTP" class="org.apache.log4j.net.SMTPAppender">

       

      <error-manager>

       

      <only-once/>

       

      </error-manager>

       

      <level name="ERROR"/>

       

      <properties>

       

      <property name="to">admin@myhost.domain.com</property>

       

      <property name="from">nobody@myhost.domain.com</property>

       

      <property name="subject">JBoss Sever Errors</property>

       

      <property name="SMTPHost">localhost</property>

       

      <property name="bufferSize">10</property>

       

      </properties>

       

      <formatter>

       

      <pattern-formatter pattern="%d %-5p [%c] (%t) %m%n"/>

       

      </formatter>

       

      </log4j-appender>

       

      -->

       

      <!-- Syslog events

       

      <log4j-appender name="SYSLOG" class="org.apache.log4j.net.SyslogAppender">

       

      <error-manager>

       

      <only-once/>

       

      </error-manager>

       

      <properties>

       

      <property name="facility">LOCAL7</property>

       

      <property name="facilityPrinting">true</property>

       

      <property name="syslogHost">localhost</property>

       

      </properties>

       

      <formatter>

       

      <pattern-formatter pattern="[%d,%c{1}] %m%n"/>

       

      </formatter>

       

      </log4j-appender>

       

      -->

       

      <!-- Log events to JMS (requires a topic to be created)

       

      <log4j-appender name="JMS" class="org.apache.log4j.net.JMSAppender">

       

      <error-manager>

       

      <only-once/>

       

      </error-manager>

       

      <level name="ERROR"/>

       

      <properties>

       

      <property name="topicConnectionFactoryBindingName">

       

      --><!-- Use injection so that an implicit dependency is formed - TODO: get the correct property name --><!--

       

      <b:inject bean="myTopicBiding" property="name"/>

       

      </property>

       

      <property name="topicBindingName">topic/MyErrorsTopic</property>

       

      </properties>

       

      </log4j-appender>

       

      -->

       

      <!-- Log events through SNMP

       

      <log4j-appender name="TRAP_LOG" class="org.apache.log4j.ext.SNMPTrapAppender">

       

      <error-manager>

       

      <only-once/>

       

      </error-manager>

       

      <level name="DEBUG"/>

       

      <properties>

       

      <property name="implementationClassName">org.apache.log4j.ext.JoeSNMPTrapSender</property>

       

      <property name="managementHost">127.0.0.1</property>

       

      <property name="managementHostTrapListenPort">162</property>

       

      <property name="enterpriseOID">1.3.6.1.4.1.24.0</property>

       

      <property name="localIPAddress">127.0.0.1</property>

       

      <property name="localTrapSendPort">161</property>

       

      <property name="genericTrapType">6</property>

       

      <property name="specificTrapType">12345678</property>

       

      <property name="communityString">public</property>

       

      <property name="forwardStackTraceWithTrap">true</property>

       

      <property name="applicationTrapOID">1.3.6.1.4.1.24.12.10.22.64</property>

       

      </properties>

       

      <formatter>

       

      <pattern-formatter pattern="%d,%p,[%t],[%c],%m%n"/>

       

      </formatter>

       

      </log4j-appender>

       

      -->

       

      <!-- Emit events as JMX notifications

       

      <log4j-appender name="JMX" class="org.jboss.monitor.services.JMXNotificationAppender">

       

      <error-manager>

       

      <only-once/>

       

      </error-manager>

       

      <level name="WARN"/>

       

      <properties>

       

      <property name="objectName">jboss.system:service=Logging,type=JMXNotificationAppender</property>

       

      </properties>

       

      <formatter>

       

      <pattern-formatter pattern="%d %-5p [%c] %m"/>

       

      </formatter>

       

      </log4j-appender>

       

      -->

       

      <!-- Security AUDIT Appender

       

      <periodic-rotating-file-handler

       

      name="AUDIT"

       

      autoflush="true"

       

      file-name="${jboss.server.log.dir}/audit.log"

       

      suffix=".yyyy-MM-dd"

       

      append="true">

       

      <error-manager>

       

      <only-once/>

       

      </error-manager>

       

      <formatter>

       

      <pattern-formatter pattern="%d %-5p [%c] (%t:%x) %m%n"/>

       

      </formatter>

       

      </periodic-rotating-file-handler>

       

      -->

       

      <!-- =============================================== -->

       

      <!-- Limit categories -->

       

      <!-- if enabling "trace" at root logger level, -->

       

      <!-- use limit category settings to disable trace -->

       

      <!-- for packages that you don't want to trace -->

       

      <!-- =============================================== -->

       

      <!-- Limit the org.apache category to INFO as its DEBUG is verbose -->

       

      <logger category="org.apache">

       

      <level name="INFO"/>

       

      </logger>

       

      <!-- Limit the jacorb category to WARN as its INFO is verbose -->

       

      <logger category="com.ibatis">

       

      <level name="DEBUG"/>

       

      <handlers>

       

      <handler-ref name="DBFILE"/>

       

      </handlers>

       

       

       

      </logger>

       

      <logger category="java.sql">

       

      <level name="INFO"/>

       

      <handlers>

       

      <handler-ref name="DBFILE"/>

       

      </handlers>

       

      </logger>

       

      <logger category="java.sql.Connection">

       

      <level name="DEBUG"/>

       

      <handlers>

       

      <handler-ref name="DBFILE"/>

       

      </handlers>

       

      </logger>

       

      <logger category="java.sql.PreparedStatement">

       

      <level name="DEBUG"/>

       

      <handlers>

       

      <handler-ref name="DBFILE"/>

       

      </handlers>

       

      </logger>

       

      <logger category="org.springframework.transaction">

       

      <level name="DEBUG"/>

       

      </logger>

       

        

       

      <logger category="org.springframework.jdbc">

       

      <level name="DEBUG"/>

       

      <handlers>

       

      <handler-ref name="DBFILE"/>

       

      </handlers>

       

       

       

      </logger>

       

        

       

       

       

      <!-- Limit JSF to INFO as its FINE is verbose -->

       

      <logger category="javax.enterprise.resource.webcontainer.jsf">

       

      <level name="DEBUG"/>

       

      </logger>

       

        

       

        

       

        

       

      <!-- Limit the org.jgroups category to WARN as its INFO is verbose -->

       

      <logger category="org.jgroups">

       

      <level name="WARN"/>

       

      </logger>

       

      <!-- Limit the org.quartz category to INFO as its DEBUG is verbose -->

       

      <logger category="org.quartz">

       

      <level name="INFO"/>

       

      </logger>

       

      <!-- Limit the com.sun category to INFO as its FINE is verbose -->

       

      <logger category="com.sun">

       

      <level name="INFO"/>

       

      </logger>

       

      <!-- Limit the sun category to INFO as its FINE is verbose -->

       

      <logger category="sun">

       

      <level name="INFO"/>

       

      </logger>

       

      <!-- Limit the javax.xml.bind category to INFO as its FINE is verbose -->

       

      <logger category="javax.xml.bind">

       

      <level name="INFO"/>

       

      </logger>

       

      <!-- Limit the springframework category to WARN-->

       

      <logger category="org.springframework">

       

      <level name="INFO"/>

       

      </logger>

       

      <!-- Limit JBoss categories

       

      <logger category="org.jboss">

       

      <level name="INFO"/>

       

      </logger>

       

      -->

       

      <!-- Or limit individual JBoss categories

       

      <logger category="org.jboss.web">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.tm">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.jdbc">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.on">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.services">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.bootstrap">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.kernel">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.beans">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.injection">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.annotation">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.system">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.mx">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.jmx">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.invocation">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.classloader">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.classloading">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.deployment">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.deployers">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.dependency">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.metadata">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.detailed">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.logging">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.logbridge">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.aop">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.joinpoint">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.util">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.ha">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.resource">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.varia">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.net">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.security">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.console">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.wsf">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.ejb">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.ejb3">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.jpa">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.vfs">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.xb">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.naming">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.wsf">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.ws">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.mail">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.monitor">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.remoting">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.profileservice">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.cache">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.proxy">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.jms">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.messaging">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.webbeans">

       

      <level name="INFO" />

       

      </logger>

       

      <logger category="org.jboss.managed">

       

      <level name="INFO" />

       

      </logger>

       

      -->

       

      <!-- Limit Arjuna transaction manager -->

       

      <logger category="com.arjuna.ats">

       

      <level name="INFO" />

       

      <handlers>

       

      <handler-ref name="DBFILE"/>

       

      </handlers>

       

      </logger>

       

      <!-- Limit Hibernate

       

      <logger category="org.hibernate">

       

      <level name="INFO" />

       

      </logger>

       

      -->

       

      <!-- Limit Ajax4jsf

       

      <logger category="org.ajax4jsf">

       

      <level name="INFO" />

       

      </logger>

       

      -->

       

      <!-- Limit JNP

       

      <logger category="org.jnp">

       

      <level name="INFO" />

       

      </logger>

       

      -->

       

        

       

      <!-- Limit the JSR77 categories -->

       

      <logger category="org.jboss.management">

       

      <level name="INFO"/>

       

      </logger>

       

        

       

       

       

      <!-- Limit the verbose ajax4jsf cache initialization

       

      <logger category="org.ajax4jsf.cache">

       

      <level name="WARN"/>

       

      </logger>

       

      -->

       

      <!-- Limit the verbose embedded jopr categories

       

      <logger category="org.rhq">

       

      <level name="WARN"/>

       

      </logger>

       

      -->

       

      <!-- Limit the verbose seam categories

       

      <logger category="org.jboss.seam">

       

      <level name="WARN"/>

       

      </logger>

       

      -->

       

      <!-- Show the evolution of the DataSource pool in the logs [inUse/Available/Max]

       

      <logger category="org.jboss.resource.connectionmanager.JBossManagedConnectionPool">

       

      <level name="TRACE"/>

       

      </logger>

       

      -->

       

      <!-- Category specifically for Security Audit Provider

       

      <logger category="org.jboss.security.audit.providers.LogAuditProvider" additivity="false">

       

      <level name="TRACE"/>

       

      <appender-ref ref="AUDIT"/>

       

      </logger>

       

      -->

       

      <!-- Limit the org.jboss.serial (jboss-serialization) to INFO as its DEBUG is verbose -->

       

      <logger category="org.jboss.serial">

       

      <level name="INFO"/>

       

      </logger>

       

      <!-- Decrease the priority threshold for the org.jboss.varia category

       

      <logger category="org.jboss.varia">

       

      <level name="DEBUG"/>

       

      </logger>

       

      -->

       

      <!-- Enable JBossWS message tracing

       

      <logger category="org.jboss.ws.core.MessageTrace">

       

      <level name="TRACE"/>

       

      </logger>

       

      -->

       

      <!-- Enable System log message tracing

       

      <logger category="org.jboss.system">

       

      <level name="TRACE"/>

       

      </logger>

       

      <logger category="org.jboss.ejb.plugins">

       

      <level name="TRACE"/>

       

      </logger>

       

      -->

       

      <!--

       

      | Logs these events to SNMP:

       

      - server starts/stops

       

      - cluster evolution (node death/startup)

       

      - When an EJB archive is deployed (and associated verified messages)

       

      - When an EAR archive is deployed

       

      <logger category="org.jboss.system.server.Server">

       

      <level name="INFO"/>

       

      <handlers>

       

      <handler-ref name="TRAP_LOG"/>

       

      </handlers>

       

      </logger>

       

      <logger category="org.jboss.ha.framework.interfaces.HAPartition.lifecycle">

       

      <level name="INFO"/>

       

      <handlers>

       

      <handler-ref name="TRAP_LOG"/>

       

      </handlers>

       

      </logger>

       

      <logger category="org.jboss.deployment.MainDeployer">

       

      <level name="ERROR"/>

       

      <handlers>

       

      <handler-ref name="TRAP_LOG"/>

       

      </handlers>

       

      </logger>

       

      <logger category="org.jboss.ejb.EJBDeployer">

       

      <level name="INFO"/>

       

      <handlers>

       

      <handler-ref name="TRAP_LOG"/>

       

      </handlers>

       

      </logger>

       

      <logger category="org.jboss.deployment.EARDeployer">

       

      <level name="INFO"/>

       

      <handlers>

       

      <handler-ref name="TRAP_LOG"/>

       

      </handlers>

       

      </logger>

       

      -->

       

      <!-- Reduce org.mc4j stuff in the logs -->

       

      <logger category="org.mc4j">

       

      <level name="WARN"/>

       

      </logger>

       

      <!-- Clustering logging -->

       

      <!-- Uncomment the following to redirect the org.jgroups and

       

      org.jboss.ha categories to a cluster.log file.

       

      <size-rotating-file-handler

       

      file-name="${jboss.server.log.dir}/cluster.log"

       

      name="CLUSTER"

       

      append="false"

       

      rotate-size="500k"

       

      max-backup-index="5"

       

      autoflush="true">

       

      <error-manager>

       

      <only-once/>

       

      </error-manager>

       

      <formatter>

       

      <pattern-formatter pattern="%d %-5p [%c] %m%n"/>

       

      </formatter>

       

      </size-rotating-file-handler>

       

      <logger category="org.jgroups">

       

      <level name="DEBUG" />

       

      <handlers>

       

      <handler-ref name="CLUSTER"/>

       

      </handlers>

       

      </logger>

       

      <logger category="org.jboss.ha">

       

      <level name="DEBUG" />

       

      <handlers>

       

      <handler-ref name="CLUSTER"/>

       

      </handlers>

       

      </logger>

       

      -->

       

      <!-- This is a temporary workaround for https://jira.jboss.org/jira/browse/EMBJOPR-280 and

       

      should be removed once that bug if fixed in the bundled admin-console war. -->

       

      <logger category="org.rhq.plugins.jbossas6.ApplicationServerComponent">

       

      <level name="FATAL"/>

       

      </logger>

       

      <!-- ======================= -->

       

      <!-- Setup the Root category -->

       

      <!-- ======================= -->

       

      <root-logger>

       

      <!-- Set the root logger priority via a system property, with a default value. -->

       

      <level name="${jboss.server.log.threshold:INFO}"/>

       

      <handlers>

       

      <handler-ref name="FILE"/>

       

       

       

      </handlers>

       

      </root-logger>

       

      </logging>

       

      I am pretty sure many of you might be using this. Please post your suggestions

       

      Thanks

      Vinaya

        • 1. Re: Per Deployement Logging in Jboss AS 6.1.0
          Wolf-Dieter Fink Master

          I think you have to separate the class loaders and maybe need to add the log4j.jar to your application.

          There is also a possibility to add a filter to the appender in the 'global' configuration which allow/deny the logging message for this appender but I can't remember exactly how and AFAIR there are performance issues.

           

          Also you should attach the config instead of posting it to prevent from scrolling You need to edit the comment, there you will find the 'attach' button