• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

best places to put log inside source code?

 
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I need some opinion about which are the best places where we should log in a source file..! Currently I am putting a log at entry, exit of method and inside the catch block.

What are the various concern places where we can log ?

I don't want to log unnecessary as later there may be file system full issue..
also Is it good to log the user private data ?

That private data can help us while debugging but is it good to log that ?
 
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Sunny,

Generally, we log something from the development perspective and from the enduser (client) perspective.

At the time of development, you can put logging statements at various places that you have mentioned so that you can track the flow of application and any malfunctioning.

But once you deliver your code to client, you should be careful that you log only those things that are necessary and can give some help to track your bugs.

And in disk space issue,

i use log4j framework where once you change the level you can stop logging the lower level logging statements.So that's not a big deal.and you don't need to remove them from code.

And there is nothing like best places.You can put it wherever required.
[ June 02, 2008: Message edited by: Vishal Pandya ]
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sunny, you can always have different levels of logging, which you can control by some input parameter to your logger framework. At basic, entry and exit logging seems fine, but yeah, for debugging you might like to see private data, sql statements, responses etc (in case if there are such things in your code)...
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may want to take a look at Aspect Ori�nted Programming (AOP) and use that approach to add generic logging advice to your classes, which in my opinion is ideally suited for the kind of logging actions you describe (on-enter, on-exit, parameters etc.).
During development the logging advice can be enabled, whereas in production it can be just as easily disabled.
 
reply
    Bookmark Topic Watch Topic
  • New Topic