0 Replies Latest reply on Apr 27, 2013 6:55 AM by jagan.rameshbabu

    Not Printing in Log File Using Log4j.xml.. I'm Getting Value in Console, But Not in File, Even file is getting Created

    jagan.rameshbabu Newbie

      Log4j.xml file


      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE log4j:configuration SYSTEM  "http://logging.apache.org/log4j/1.2/apidocs/org/

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

      <appender name="fileAppender" class="org.apache.log4j.RollingFileAppender">
      <param name="File" value="Logger.log" />
      <param name="Append" value="true"/>
      <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d %-5p %c{1}:%L %m %n" />

      <appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
      <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d %-5p %c{1}:%L %m %n" />

      <!-- sets the priority log level for org.springframework -->

      <logger name="org.springframework">
      <level value="info" />

      <!-- sets the default priority log level -->

      <priority value="info"></priority>
      <appender-ref ref="fileAppender" />
      <appender-ref ref="consoleAppender" />




      Web.xml file


      <?xml version="1.0" encoding="UTF-8"?>
      <web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" >

      <!-- location of log4j config file -->





              <!-- applies log4j configuration -->


             <servlet-class> --- </servlet-class>




      Action Class


      public class logsample {

      static final Logger logger = Logger.getLogger("logsample.class");
      DOMConfigurator.configure("C:/---- location path of my log4j.xml file----");
      .info("FileAppender Message ==> HI");




      I placed my log4j.xml file in both places, JBOSS 7.1.0/bin/log4j.xml and also in web-inf/classes/log4j.xml Correct me if i'm Wrong? I'm Using Eclipse Indigo, JBOSS 7.1.0 final, Maven build tool, and its a struts2-springAOP based app.


      1. Am i need to include jboss-deployment-structure file?

      2. Am i need to include log4j.jar? if yes, then in which location?

      3. Any Issues in my code? if Yes, Please Correct Me..

      4. log4j works in JBoss 7.1.0 or not??? if Yes, Where do i need to put these files to deploy my app successfully?