jfreechart 0.9.17 and log4j problem and suggestion
jfreechart 0.9.17 and log4j problem and suggestion
Hello,
I have noticed that new jfreechart depends on log4j.
I am using it in applet so this gives me another library to download without any added functionality.
My suggestion is to make this dependecy optional - for example wrap
all calls to logger in separate class (so loading logj4 will not be necessary) and allow to disable logging on startup
(it seems to be possible in jfreereport).
Anyway - I really like your work,
Kuba
I have noticed that new jfreechart depends on log4j.
I am using it in applet so this gives me another library to download without any added functionality.
My suggestion is to make this dependecy optional - for example wrap
all calls to logger in separate class (so loading logj4 will not be necessary) and allow to disable logging on startup
(it seems to be possible in jfreereport).
Anyway - I really like your work,
Kuba
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
OK, a fair point, I'll see what I can do about it.
There aren't that many classes with logging in them yet, so for a workaround you could probably search for the logging statements, remove them and rebuild the jar files.
There aren't that many classes with logging in them yet, so for a workaround you could probably search for the logging statements, remove them and rebuild the jar files.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


I had a problem once involving a jar that wasn't available to all clients.
I wrote a proxy class that used the reflection api reflection to check if the extra classes was available. If they were then I used the reflection api to create the objects and pass the calls, otherwise I just passed back default values. This way you gain the extra functionality by adding/removing the classes from the class path without needing to recompile. Not the neatest or fastest way to do it, but it did decouple the dependencies nicely, and still allowed us to have only one binary.
Otherwise, perhaps include an ant build script with flags for adding debugging if required.
I wrote a proxy class that used the reflection api reflection to check if the extra classes was available. If they were then I used the reflection api to create the objects and pass the calls, otherwise I just passed back default values. This way you gain the extra functionality by adding/removing the classes from the class path without needing to recompile. Not the neatest or fastest way to do it, but it did decouple the dependencies nicely, and still allowed us to have only one binary.
Otherwise, perhaps include an ant build script with flags for adding debugging if required.
I'd also like to see optional logging.
My chart-generating servlet log is now filled with charting info messages. The problem is I occasionally generate some info-level log messages I would like to see. Is there a way to turn off or change the logging levels for jfreechart globally, short of removing all the logging code and rebuilding? If not, that might be a nice future feature as well: not only should logging be optional, but if you choose to use logging, logging options should be configurable (either via a properties file or perhaps on the fly using a singleton config class).
My chart-generating servlet log is now filled with charting info messages. The problem is I occasionally generate some info-level log messages I would like to see. Is there a way to turn off or change the logging levels for jfreechart globally, short of removing all the logging code and rebuilding? If not, that might be a nice future feature as well: not only should logging be optional, but if you choose to use logging, logging options should be configurable (either via a properties file or perhaps on the fly using a singleton config class).
Just add the following to log4j.xml:admm wrote:Is there a way to turn off or change the logging levels for jfreechart globally, short of removing all the logging code and rebuilding?
Code: Select all
<category name="org.jfree.chart">
<priority value="WARN"/>
</category>
IMHO that's a lot of effort better spent elsewhere. I think it would suffice if the sub-surface stuff ("entering function draw()") that's currently being logged as INFO is instead logged as DEBUG or TRACE from the next release onward.If not, that might be a nice future feature as well: if you choose to use logging, logging options should be configurable.
IIRC there is no TRACE-Level in log4j. They discussed the introduction of a TRACE-Level in log4j a few month ago on their list.IMHO that's a lot of effort better spent elsewhere. I think it would suffice if the sub-surface stuff ("entering function draw()") that's currently being logged as INFO is instead logged as DEBUG or TRACE from the next release onward.
But anyway, switching levels on or off at runtime from whereever you want is IMHO a clear requirement to log4j, not to JFreeChart.
If you don't want or don't use log4j logging, i'd recommend to switch off Logging for jfreechart at all, this gains some performance as well:
For .properties-File
Code: Select all
log4j.logger.org.jfree = OFF
Code: Select all
<category name="org.jfree.chart">
<priority value="OFF"/>
</category>
http://www.jfree.org/phpBB2/viewtopic.php?t=8029
HTH
cheers
Heinrich
PS: there is a nice but german articel about JFreeChart in the German LinuxMagazin Mai 2004.
Garv,

Which classes are you using?
I cant find Level Trace wheter in javap org.apache.log4j.Level nor in javap java.util.logging.Level.
What am I missing?
But I guess this tends to be OT anyway.
===================
See http://nagoya.apache.org/wiki/apachewik ... JDKLogging for more reasons on that.
Cheers
Heinrich
Gee, my eclipse seems to be brokengarv wrote:According to autocompletion in Eclipse, there ishank wrote:IIRC there is no TRACE-Level in log4j..

Which classes are you using?
I cant find Level Trace wheter in javap org.apache.log4j.Level nor in javap java.util.logging.Level.
What am I missing?
But I guess this tends to be OT anyway.
===================
What, if I have to use JDK 1.3?Guest wrote:why don't you use the Java logging API instead? this way, you won't depend on another 3rd party library and still have logging (JDK 1.4). other than that, this is a big stopper on upgrading to a new version of JFreeChart.
See http://nagoya.apache.org/wiki/apachewik ... JDKLogging for more reasons on that.
Cheers
Heinrich
hank wrote:Garv,Gee, my eclipse seems to be brokengarv wrote:According to autocompletion in Eclipse, there ishank wrote:IIRC there is no TRACE-Level in log4j..
Which classes are you using?
I cant find Level Trace wheter in javap org.apache.log4j.Level nor in javap java.util.logging.Level.

Straight from Log4j-1.2.8.jar...
D'oh! It's in commons-logging!
ahh, thanks for this solution.garv wrote:D'oh! It's in commons-logging!
Have a nice and recovering weekend, Garv!
cheers
Heinrich