title: Logging with DEBUG level in JBoss 7.1.1
body: <p>Goal: My application should have messages with ERROR and DEBUG levels. Level of logging must set (switch) via JBoss Admin Console. Logging should be written to standard JBoss log file and server console.</p>
  
  <p>I tried to use java.util.logging.Logger, but this logger have not necessary levels.
  I switched to log4j with slf4j. Messages with ERROR level is exist. Problem with DEBUG and  System.out.println.
  Interesting, that DEBUG level is visible in testing phase.</p>
  
  <pre><code> import org.slf4j.Logger;
      import org.slf4j.LoggerFactory;
      /**
       * Logger creation and configuration
       */
      public class ResourcesLog {
  
          @Produces
          Logger getLog(InjectionPoint ip) {
              String category = ip.getMember().getDeclaringClass().getName();
              return LoggerFactory.getLogger(category);
          }
      }
  </code></pre>
  
  <p>or just LOG = LoggerFactory.getLogger(MyClass.class);
  Pom file:</p>
  
  <pre><code>&lt;dependency&gt;
              &lt;groupId&gt;log4j&lt;/groupId&gt;
              &lt;artifactId&gt;log4j&lt;/artifactId&gt;
              &lt;version&gt;1.2.17&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
              &lt;version&gt;1.7.6&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
              &lt;version&gt;1.7.6&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
              &lt;version&gt;1.7.6&lt;/version&gt;
  
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;slf4j-simple&lt;/artifactId&gt;
              &lt;version&gt;1.7.6&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>Maybe contains unnecessary. I can't set slf4j-simple and slf4j-api as "provided" - got an error. Should this libs be inside war?</p>
  
  <p>jboss-deployment-structure.xml in WEb-INF:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;jboss-deployment-structure&gt;
      &lt;deployment&gt;
          &lt;exclusions&gt;
              &lt;module name="org.apache.commons.logging" /&gt;
              &lt;module name="org.apache.log4j" /&gt;
              &lt;module name="org.jboss.logging" /&gt;
              &lt;module name="org.jboss.logging.jul-to-slf4j-stub" /&gt;
              &lt;module name="org.jboss.logmanager" /&gt;
              &lt;module name="org.jboss.logmanager.log4j" /&gt;
              &lt;module name="org.slf4j" /&gt;
              &lt;module name="org.slf4j.impl" /&gt;
          &lt;/exclusions&gt;
      &lt;/deployment&gt;
  &lt;/jboss-deployment-structure&gt;
  </code></pre>
  
  <p>And log4j.xml settings in resource folder (in war is in 'WEB-INF/classes/log4j.xml'):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
          &lt;!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"&gt;
  &lt;log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false"&gt;
      &lt;appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender"&gt;
          &lt;errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/&gt;
          &lt;param name="File" value="${jboss.server.log.dir}/server.log"/&gt;
          &lt;param name="Append" value="true"/&gt;
          &lt;param name="DatePattern" value="'.'yyyy-MM-dd"/&gt;
          &lt;layout class="org.apache.log4j.PatternLayout"&gt;
              &lt;param name="ConversionPattern" value="%d %-5p [%c] %m%n"/&gt;
          &lt;/layout&gt;
      &lt;/appender&gt;
      &lt;appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"&gt;
          &lt;errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/&gt;
          &lt;param name="Target" value="System.out"/&gt;
          &lt;param name="Threshold" value="DEBUG"/&gt;
          &lt;layout class="org.apache.log4j.PatternLayout"&gt;
              &lt;param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/&gt;
          &lt;/layout&gt;
      &lt;/appender&gt;
      &lt;category name="org.mypackage"&gt;
          &lt;priority value="DEBUG"/&gt;
      &lt;/category&gt;
      &lt;root&gt;
          &lt;level value="INFO"/&gt;
          &lt;appender-ref ref="CONSOLE"/&gt;
          &lt;appender-ref ref="FILE"/&gt;
      &lt;/root&gt;
  &lt;/log4j:configuration&gt;
  </code></pre>