6 Replies Latest reply on Jan 12, 2014 12:58 AM by Haroon Foad

    jboss4.2.3 to Jboss7.1 final custom log4j issue

    thinksteep thinksteep Novice

      Hi Community,

       

      With the help of community here we have migrated most of the application from 4.2.3a to 7.1. One issue we are struggling is, log4j configuration.

       

      In 4.2.3a we have custom log4j.xml (under conf folder) for application which logs messages to application specific log. We are not clear on how to migrate this part to 7.1 Final. Any help would be really appreciated.

       

      Attached server.log.

       

      Thanks for your time and help.

        • 1. Re: jboss4.2.3 to Jboss7.1 final custom log4j issue
          thinksteep thinksteep Novice

          Here is another observation, all log messages are being logged to server.log instead of my application log. I am suspecting some configuration change required in jboss7.1 to change it from server.log to my application log. Any pointers?

           

          Thanks for your time and help.

          • 2. Re: jboss4.2.3 to Jboss7.1 final custom log4j issue
            thinksteep thinksteep Novice

            Anyone to help on this issue?

             

            I  just wrote sample app based on discussion in below link

            https://community.jboss.org/message/622668#622668#622668

             

            It is also not working. Not logging anything.

             

            My test servlet code is below:

             

            System.out.println("Logger tewst"+logger.getAppender("MyAppender"));  returning null. I couldn't understand why.

             

             

            public class TestServlet extends HttpServlet {

             

                Logger logger = Logger.getLogger("org.weld");

             

                /**

                 * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.

                 * @param request servlet request

                 * @param response servlet response

                 * @throws ServletException if a servlet-specific error occurs

                 * @throws IOException if an I/O error occurs

                 */

                protected void processRequest(HttpServletRequest request, HttpServletResponse response)

                        throws ServletException, IOException {

                    response.setContentType("text/html;charset=UTF-8");

                    PrintWriter out = response.getWriter();

                    try {

             

                        System.out.println("Inside process request");

                        System.out.println("Logger tewst"+logger.getName());

                        System.out.println("Logger tewst"+logger.getAppender("MyAppender"));

                        

                        logger.debug("-->init");

             

                        logger.debug("<--init");

                      

                        out.println("<html>");

                        out.println("<head>");

                        out.println("<title>Servlet TestServlet</title>"); 

                        out.println("</head>");

                        out.println("<body>");

                        out.println("<h1>Servlet TestServlet at " + request.getContextPath () + "</h1>");

                        out.println("</body>");

                        out.println("</html>");

                    } finally {

                        out.close();

                    }

                }

             

                // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">

                /**

                 * Handles the HTTP <code>GET</code> method.

                 * @param request servlet request

                 * @param response servlet response

                 * @throws ServletException if a servlet-specific error occurs

                 * @throws IOException if an I/O error occurs

                 */

                @Override

                protected void doGet(HttpServletRequest request, HttpServletResponse response)

                        throws ServletException, IOException {

                    logger.debug("-->doGet");

             

                    processRequest(request, response);

                    logger.debug("<--doGet");

                }

             

                /**

                 * Handles the HTTP <code>POST</code> method.

                 * @param request servlet request

                 * @param response servlet response

                 * @throws ServletException if a servlet-specific error occurs

                 * @throws IOException if an I/O error occurs

                 */

                @Override

                protected void doPost(HttpServletRequest request, HttpServletResponse response)

                        throws ServletException, IOException {

                    logger.debug("-->destroy");

                    processRequest(request, response);

                    logger.debug("<--destroy");

                }

             

                /**

                 * Returns a short description of the servlet.

                 * @return a String containing servlet description

                 */

                @Override

                public String getServletInfo() {

                    return "Short description";

                }// </editor-fold>

            }

             

             

            Attached war file for reference.

             

            Any help would be really appreciated.

             

            Thanks for your time and help.

            • 3. Re: jboss4.2.3 to Jboss7.1 final custom log4j issue
              thinksteep thinksteep Novice

              Never mind. I was able to fix it. It was issue with log4j exclusion entry in jboss-deployment-structure.xml file

               

              Thanks for your time.

              • 4. Re: jboss4.2.3 to Jboss7.1 final custom log4j issue
                Haroon Foad Newbie

                Dear thinksteep,

                I have posted almost the same discussion on:

                https://community.jboss.org/thread/198075?tstart=0

                 

                any idea you can help me in this issue.

                • 5. Re: jboss4.2.3 to Jboss7.1 final custom log4j issue
                  Vineela Gampa Novice

                  What did you do to fix this ? Iam having similar problem with my application , woudl be great if you could share your approach.

                   

                   

                  Thnaks