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
  • 3
    by... using a logger? vogella.com/articles/Logging/article.html Commented Feb 20, 2013 at 6:52
  • @Najzero I dont know which is best.But I try this. Thanks buddy :) Commented Feb 20, 2013 at 7:04

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.