3 Replies Latest reply on Aug 28, 2012 2:10 PM by James Perkins

    How write an EJB's logs to console?

    Wouter De Borger Newbie

      Hi all,

       

      I've been trying to get the log generated by an EJB component to be written to disk (on as 7.1).

       

      The EJB has the following code:

       

      private static Logger log = Logger.getLogger("e2e");

       

      log.trace("Test Message);

       

       

      I configured the logging framework:

       

      <logger category="e2e" use-parent-handlers="false">

                      <level name="ALL"/>

                      <handlers>

                          <handler name="CONSOLE"/>

                      </handlers>

      </logger>

      <console-handler name="CONSOLE">

                      <level name="ALL"/>

                      <formatter>

                          <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>

                      </formatter>

      </console-handler>

       

      I used a debugger to verify that the log call is beeing made.

       

      And yet, nothing is being written to the log stream.

       

      What am I doing wrong?

       

      Thanks in advance,

      Wouter

        • 1. Re: How write an EJB's logs to console?
          Wolf-Dieter Fink Master

          The formatter pattern is not relevant for this.

          If you look into the logging subsystem configuration the root-logger is set to INFO level, also the console appender is restricted to INFO level.

           

          You might remove the INFO level from the console appender or you have to look in the server.log file.

          If you do not want a very noisy logging you have to add a new logger category element "e2e" to the configuration an set the level=TRACE.

           

          You should use a fresh, unchanged configuration to test it, If that will not work attach the logging-subsystem configuration.

          • 2. Re: How write an EJB's logs to console?
            Wouter De Borger Newbie

            Hi,

             

            I tried to attach the logging config in the previous post, but it seems to have gone wrong.

            Here it is again.

             

              <subsystem xmlns="urn:jboss:domain:logging:1.1">

                        <console-handler name="CONSOLE">

                            <level name="ALL"/>

                            <formatter>

                                <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>

                            </formatter>

                        </console-handler>

                        <periodic-rotating-file-handler name="FILE">

                            <formatter>

                                <pattern-formatter pattern="%d{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="com.arjuna">

                            <level name="WARN"/>

                        </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>

                        <logger category="e2e" use-parent-handlers="false">

                            <level name="ALL"/>

                            <handlers>

                                <handler name="CONSOLE"/>

                            </handlers>

                        </logger>

                        <root-logger>

                            <level name="INFO"/>

                            <handlers>

                                <handler name="CONSOLE"/>

                                <handler name="FILE"/>

                            </handlers>

                        </root-logger>

                    </subsystem>

            • 3. Re: How write an EJB's logs to console?
              James Perkins Master

              That should work. I configured my logging subsystem to look like the following and I'm getting TRACE and DEBUG messages to the console.

               

                      <subsystem xmlns="urn:jboss:domain:logging:1.1">
                          <console-handler name="CONSOLE">
                              <level name="ALL"/>
                              <formatter>
                                  <pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
                              </formatter>
                          </console-handler>
                          <periodic-rotating-file-handler name="FILE" autoflush="true">
                              <formatter>
                                  <pattern-formatter pattern="%d{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="com.arjuna">
                              <level name="WARN"/>
                          </logger>
                          <logger category="org.apache.tomcat.util.modeler">
                              <level name="WARN"/>
                          </logger>
                          <logger category="org.jboss.as.config">
                              <level name="DEBUG"/>
                          </logger>
                          <logger category="sun.rmi">
                              <level name="WARN"/>
                          </logger>
                          <logger category="jacorb">
                              <level name="WARN"/>
                          </logger>
                          <logger category="jacorb.config">
                              <level name="ERROR"/>
                          </logger>
                          <logger category="org.jboss.as.server.deployment.scanner" use-parent-handlers="false">
                              <level name="ALL"/>
                              <handlers>
                                  <handler name="CONSOLE"/>
                              </handlers>
                          </logger>
                          <root-logger>
                              <level name="INFO"/>
                              <handlers>
                                  <handler name="CONSOLE"/>
                                  <handler name="FILE"/>
                              </handlers>
                          </root-logger>
                      </subsystem>
              
              
              

               

              --

              James R. Perkins