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?
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.
You can try log4j for all kind of logging use cases. http://logging.apache.org/log4j/1.2/