dcsimg
What Pattern to use?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   shiva_prasad
Posted On:   Friday, October 17, 2003 12:37 PM

			

I have jdk1.4 on one machine and 1.3 on another machine. I
would like to use 1.4 logging if 1.4 is available else
custom logging. I have two LogUtil classes (LogUtil.java
and LogUtil14.java).

Depending on the situation I would like to use that
particular logging. Unfortuantely, I have coded LogUtil14
in all the classes and I want to give some linking to 1.3
or 1.4 from LogUtil14 only. How can I avoid
SecurityException? What is the creational-pattern I can use
here? Help me.

Thanks

Re: What Pattern to use?

Posted By:   Stephen_McConnell  
Posted On:   Saturday, October 18, 2003 11:26 AM

I've run into the same type of problem. I solved it by changing all my logging references to use the Jakarta Common Logging API's.


As a developer, in your code where you have all your "log.info(..", "log.debug(...." etc statements there is no difference. The only thing you have to do is change the static reference where you define your Logger at the start of each class where you have logging. And then, where it is first initialized.


You then create an initialization property file that points to what type of logging you are doing. They have created a LogFactory that figures out whether you are using log4j, java logging classes or a "Simple" logger class of their implementation. This saves lots of "re-coding" in future projects. And the code will run on JDK 1.3 and JDK 1.4 with just a change in the config file.


Here's a link to it Jakarta Commons Logging.


Good Luck.


Stephen McConnell

About | Sitemap | Contact