1

I want to log what methods and what values are called in my java program in a text file or data base.

      For example:========================================

      this my java program


     Class A
      { 



        public void hello()

         {

           if(call.equalsto("world")
          {

           helloworld();
           }

            if(call.equalsto("boy")
          {

           helloboy();
           }

            if(call.equalsto("girl")
                        {

           hellogirl();
           }

           }


      public void helloworld()
           {


          system.out.println("hi world")
           }


        public void helloboy()
           {


          system.out.println("hi boy")
           }

                public void hellogirl()
           {


          system.out.println("hi girl")
           }

       }

So I call methods based on the input type. How to log which method is called and which value is printed as log in a text file or database?

2

2 Answers 2

2

You can use any Java logger, take log4j for example, its good documented and simple to use, take a look at this example and this one.

You can download it here.

There are several other logging tool for java, see a comparision on this list.

0

You can try log4j for all kind of logging use cases. http://logging.apache.org/log4j/1.2/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.