• Post Reply Bookmark Topic Watch Topic
  • New Topic

What is the best approach to debug your code with Logs  RSS feed

 
Christian Klugesherz
Ranch Hand
Posts: 103
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm currently trying to find the best way to troubleshoot my code in case of issues.
What is the best approach ?
The goal is to have
* different level of log depths : logl=
* different methods to troubleshoot : logmeth =

The final goal would be to rund the code like following
   codetorun logl=3 logmeth=class1+class5+class7

Is there an approach to not slow down the execution with a lot of

For now I'm using a test class, and I'm trying to implement an auto-test before each release, this should prevent of the most issues, but in case there is something to debug, logs are the most flexible.

Thanks in advance for your advice

Christian
 
Dave Tolls
Ranch Foreman
Posts: 3067
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What log system are you using?

Pretty much any logging framework has a LogLevel you can supply to the logging calls (TRACE, DEBUG, WARNING, ERROR, that sort of thing), and a launch parameter that allows you to tell the system at start up what minimum level you want to log.  So DEBUG in testing, and WARNING in production, for example.
 
Christian Klugesherz
Ranch Hand
Posts: 103
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:What log system are you using?

What do you mean with that ?
I was not aware that there are Log Systems.

FYI as IDE I'm using Eclipse which some times complete the code automatically with

Is that, what your are calling the log System ?

My basic approach was to implement something like following

But what I understood, there is a class which already implements all this stuff 

Thanks for complement
 
Dave Tolls
Ranch Foreman
Posts: 3067
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java has an inbuilt logging system (JavaDoc), but I've not seen that used in too many places.

There's Apache's log4j, which I've seen used in several projects, and as the basis for other systems.

These should give you an idea of what these packages do that you might want to emulate if you write your own.
 
Christian Klugesherz
Ranch Hand
Posts: 103
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,
I will take a look in Log4j which seems to be the most used.

Christian
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!