Java Logging - Wrapper? -


i starting new project , have done considerations logging. used pattern every class, in logging done, has own static logger:

private static final logger logger = logger.getlogger(logginginterceptor.class); 

i not approach have copy line every class log something. considered using android approach there log class it's static methods log. started searching on internet similar approach done else, did not find anything.

so question is: disatvantages of approach?

i cannot think of rather of advantages, follows dry pattern. different categories handled in android 'tags', parameters of static log methods. example:

 log.debug(tag, message, exception); 

the log class use common logging framework such log4j or slf4j.

so interested in opinions.

based on java.util.logging.logger api , this article, main reason getlogger() ensure same logger , handler set used independently between subsystems.

java's recommended solution obtain logger @ top of each file, , log object every time need to.

using static log.debug require tag processed each time correct handler set being used. thus, less efficient having log object ready go.

however, if not using handlers, or not differentiating between subsystems, static functions reasonable shortcut, long library used suited needs.


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -