如何在数据库中记录我的java程序流? [英] how to log my java program flow in database?
本文介绍了如何在数据库中记录我的java程序流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如:===================== =================
这个我的java程序
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)
}
}
所以我根据输入类型调用方法。如何记录哪个方法被调用,哪个值打印为文本文件或数据库中的日志?
解决方案
您可以使用任何Java记录器,以 log4j 为例,其良好的记录和易于使用,请查看<一个href =http://www.tutorialspoint.com/log4j/log4j_sample_program.htm =nofollow>这个例子和这个。
你可以下载它这里
还有其他几个java的日志记录工具,见比较此列表。
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.
这篇关于如何在数据库中记录我的java程序流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文