9 Replies Latest reply on Aug 18, 2008 5:32 PM by Daniel Genkin

    IPs and URLs logging in JBoss

    Daniel Genkin Newbie

      Hi,

      This is my first post and I am new with JBoss, so I am sorry in advance, if this is not a correct section for this post.

      We have recently switched from Oracle AS to JBoss AS. All our app servers are in a cluster in a load balancer.
      When we were using Oracle and Apache http for all incoming requests, I was able to configure the load balancer to pass original IP (X-Forwarded-For) to Apache http to log client's IP and configured Apache to log a URL client is calling.

      After we switched to JBoss we are not using http for incoming requests anymore. I am still passing the x-forwarded-for from the load balancer, but all the requests from the load balancer are now bypassing Apache and going directly into JBoss. Apache is used only by JVM for redirecting internal requests to get static resources. So Apache cannot be used to log client's IP or URL.

      So the question is: Is there a way to configure JBoss (maybe through log4j?) to log incoming IPs and URls and if yes, then how?

      Thank you very much in advance.

      Daniel

        • 1. Re: IPs and URLs logging in JBoss
          Daniel Genkin Newbie

          Nobody had to ever log IPs in JBoss?:)

          • 2. Re: IPs and URLs logging in JBoss
            Peter Johnson Master

            Try uncommenting the RequestDumperValve in server.xml and see if that does it.

            In JBossAS 4.2.3, server.xml is located at server/xxx/deploy/jboss-web.deployer

            • 3. Re: IPs and URLs logging in JBoss
              Daniel Genkin Newbie

               

              "PeterJ" wrote:
              Try uncommenting the RequestDumperValve in server.xml and see if that does it.

              In JBossAS 4.2.3, server.xml is located at server/xxx/deploy/jboss-web.deployer



              Thanks, Peter. This provides excessvie logging, unfortunately.
              I have found another interesting thing in the server.xml for access logging and this is actually what i need, but i cannot find where i specify the pattern.
              Below is this logger funtionality. It has pattern='combined', can be 'common'. Where do i specify this pattern details? I need to add something like this LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined. Then i will log everything i need.


              <!-- Access logger -->




              • 4. Re: IPs and URLs logging in JBoss
                Daniel Genkin Newbie

                By some reason it cut my last post. I am reposting it:

                "PeterJ" wrote:
                Try uncommenting the RequestDumperValve in server.xml and see if that does it.

                In JBossAS 4.2.3, server.xml is located at server/xxx/deploy/jboss-web.deployer



                Thanks, Peter. This provides excessvie logging, unfortunately.
                I have found another interesting thing in the server.xml for access logging and this is actually what i need, but i cannot find where i specify the pattern.
                Below is this logger funtionality. It has pattern='combined', can be 'common'. Where do i specify this pattern details? I need to add something like this LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined. Then i will log everything i need.


                <!-- Access logger -->
                by some reason the details of the access logger are getting cut here, unless i dont remove opening and closing tags, so i had to remove them:

                <!--
                Valve className="org.apache.catalina.valves.AccessLogValve"
                prefix="access_log." suffix=".log"
                pattern="combined" directory="/log"
                resolveHosts="false"
                -->

                • 5. Re: IPs and URLs logging in JBoss
                  Peter Johnson Master

                  Use the code tags around XML text - select the text and click the Code button under the editor window. And preview the post before submitting it.

                  • 6. Re: IPs and URLs logging in JBoss
                    Daniel Genkin Newbie

                     

                    "PeterJ" wrote:
                    Use the code tags around XML text - select the text and click the Code button under the editor window. And preview the post before submitting it.



                    Thanks for the advice. Do you have advice to my other question about where i can modify common and combined patterns used in Access Logger in server.xml?

                    • 7. Re: IPs and URLs logging in JBoss
                      Peter Johnson Master

                      Not having tried it myself, no.

                      • 8. Re: IPs and URLs logging in JBoss
                        Daniel Genkin Newbie

                         

                        "PeterJ" wrote:
                        Not having tried it myself, no.

                        ok, thnx. maybe somebody else has.

                        i was trying to find in google where these directives are defined for server.xml, but no luck....

                        • 9. Re: IPs and URLs logging in JBoss
                          Daniel Genkin Newbie

                          After trials and errors found how to log what i wanted. The following needs to be specified in the server.xml:


                          <Valve className="org.apache.catalina.valves.AccessLogValve"
                           prefix="access_log." suffix=".log"
                           pattern="%{X-Forwarded-For}i %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
                           directory="$JBOSS_LOGS"
                           resolveHosts="false" />
                          


                          Note that instead of " i have to use "