7 Replies Latest reply on Jan 2, 2013 11:32 AM by techsjs2012

    Using Log4J in AS7


      I'm trying to get a number of logging mechanisms to work in AS7 (standalone mode) in the context of JBAS-8429.

      JBoss logging works fine for me and my log messages appear nicely in the standalone/logs/boot.log file.


      However Log4J messages don't get through yet. Can I configure Log4J such that it sends its log messages to the same destination as JBoss Logging?

      Once I've done Log4J I'd also like JUL, apache commons logging and SLF4J all to go to the same destination. Any tips for these?

        • 1. Re: Using Log4J in AS7

          JBoss LogManager supports frontends for all logging frameworks; I haven't integrated some of them yet because they aren't used by any internal components.  Here's the breakdown:


          • Log4j - requires the log4j bridge implementation, not yet integrated
          • JUL - natively supported by LogManager (done)
          • Commons Logging - implemented using the "org.apache.commons.logging" module (which just reexports jcl-over-slf4j) (done)
          • SLF4J - (done)
          • JBoss Logging - (done)


          I think that covers all the major ones.  If you open a JBAS issue for log4j and assign it to me, I'll get to it ASAP.

          • 2. Re: Using Log4J in AS7

            This page has some relevant info: Standalone JBoss LogManager

            1 of 1 people found this helpful
            • 3. Re: Using Log4J in AS7

              Thanks for the info, David. I've created https://jira.jboss.org/browse/JBAS-8459

              • 4. Re: Using Log4J in AS7

                OK, it should be working now.   Log4j appears as "org.apache.log4j" in the module repository.

                • 5. Re: Using Log4J in AS7

                  Excellent! That all works now. Many thanks.

                  • 6. Re: Using Log4J in AS7



                    Can someone step me thru how to setup log4j on JBoss AS7?

                    I've tried the following.


                    I have an EJB Jar file which has a "log4j.properties" file.


                    This same JAR file will log correctly on other AppServers (such as Glassfish).


                    I read else where that I must do the following in my "standalone.xml" file:

                    <size-rotating-file-handler name="MY_LOGGER">

                        <level name="TRACE"/>


                            <pattern-formatter pattern="%d{MMM-dd hh:mm:ss} [%c{1}] %m%n"/>


                        <file relative-to="jboss.server.log.dir" path="myLogger.log"/>

                        <rotate-size value="9216K"/>

                        <max-backup-index value="3"/>


                    <logger category="com.mycompany">

                        <level name="TRACE"/>


                            <handler name="MY_LOGGER"/>




                    I tried that and it still doesn't work


                    I don't want to do anything fancy. All I want is for my log statements to be written in a file called "myLogger.log".


                    Any help would be appreciated.

                    • 7. Re: Using Log4J in AS7

                      Looks like I am having the same issues moving project that are Spring, Log4J from tomcat to JBoss AS7.. Can someone please give me a breakdown of the steps I have to take to get this working