How do I register my Java program thread in the database?

I want to record what methods and what values ​​are called in my java program in a text file or database.

      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 am calling methods based on the input type. How do I log which method is called and which value is printed as a write to a text file or database?

+1


source to share


2 answers


You can use any Java logger like log4j , its well documented and easy to use, check out this example and this one .

You can download it here.



There are several other logging tools for java, see a comparison of this list .

+2


source


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



0


source







All Articles