9 Replies Latest reply on Jul 4, 2013 9:44 AM by Stephen Coy

    Log4j logging problem

    gmgallo Newbie

      Hi guys


      I have finally started to use jboss7 (previously I used jboss4 and jboss5) and now I don't know how to use an external file for log4j configuration. In the specific I have a simple ejb project with a starter class that has the following code:





      public class Starter {



                public static final Logger LOGGER = Logger.getLogger(Starter.class);




                void init() {



                          System.out.println("Starting MSH backend");



                          System.out.println("Configuring properties");



                          try {




                                    System.out.println("Properties loaded, configuring loggers");


                                    System.out.println("Loggers configured");


                                    LOGGER.info("MSH EJB STARTED");




                          catch(IOException e) {



                                    System.out.println("ERROR! Props file not found!");




                          catch(PropertyNotFoundException e) {


                                    System.out.println("ERROR! Logger filename property not found");












      Simply I use DomConfigurator to read an external log4j configuration file and to configure the logger properly. This is the content of the xml file:




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



      <!DOCTYPE log4j:configuration SYSTEM "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">

      <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">


          <appender name="mshEjb" class="org.apache.log4j.DailyRollingFileAppender">

              <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>

              <param name="Append" value="true"/>

              <param name="File" value="/var/opt/msh/msh_ejb.log"/>

              <layout class="org.apache.log4j.PatternLayout">

                  <param name="ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss.SSS} [%C{1}] - %m%n"/>




          <category name="com.stonesoft.msh.ejb" additivity="false">

              <priority value="DEBUG"/>

              <appender-ref ref="mshEjb"/>






      The problem is that the application creates the log file correctly but nothing is written in it. In the server.log instead I can find both the standard print and the log print. I've tried all the ways I found in internet without luck. Any idea?