A good style of logging is recommended in the developing practice. Basically, you need to enable logging in two major steps – initialization and individual source classes.
Applications normally consist of different components and are deployed in a distributed environment. Typically, there has to be a common initialization routine for a component. Logging configuration, such as setting severity, can also be done at this stage..
A top-down approach is used, that is, defining a basic configuration at a higher level (component-oriented parent node). Most of the time you do not need to tune the logging behavior in such details for each class. In this case, a basic configuration at the top level is good enough to get the logging started. Only when specific setting has to be done individually for certain classes, you can enable that in the class level.
In the individual class, it is recommended to have a static variable to hold the access to the location object (for better performance) and then start inserting messages:
static Location _loc = Location.getLocation(<classname>.class); … … _loc.infoT(… … ….); _loc.errorT(… … ….); |