jfreechart 0.9.17 and log4j problem and suggestion

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
cube
Posts: 22
Joined: Tue Mar 30, 2004 11:26 am
Contact:

jfreechart 0.9.17 and log4j problem and suggestion

Post by cube » Tue Mar 30, 2004 11:41 am

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

Guest

Post by Guest » Tue Mar 30, 2004 9:56 pm

I agree. 0.9.16 was better in this respect.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Wed Mar 31, 2004 11:34 am

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.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Guest

Post by Guest » Thu Apr 01, 2004 12:43 am

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.

admm
Posts: 3
Joined: Sat Mar 27, 2004 1:13 am

Post by admm » Thu Apr 01, 2004 1:22 am

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).

garv
Posts: 127
Joined: Wed Mar 31, 2004 3:44 pm
Location: Amsterdam, The Netherlands

Post by garv » Thu Apr 01, 2004 9:07 am

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?
Just add the following to log4j.xml:

Code: Select all

<category name="org.jfree.chart">
<priority value="WARN"/>
</category>
If not, that might be a nice future feature as well: if you choose to use logging, logging options should be configurable.
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.

hank
Posts: 31
Joined: Mon May 12, 2003 10:02 am
Location: Lake of Constance, Germany

Post by hank » Fri Apr 02, 2004 9:57 am

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.
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.
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
for .xml-File:

Code: Select all

<category name="org.jfree.chart">
<priority value="OFF"/>
</category>
You may also do it programmatically, see thread:

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
Posts: 127
Joined: Wed Mar 31, 2004 3:44 pm
Location: Amsterdam, The Netherlands

Post by garv » Fri Apr 02, 2004 10:42 am

hank wrote:IIRC there is no TRACE-Level in log4j.
According to autocompletion in Eclipse, there is ;).

Guest

Post by Guest » Fri Apr 02, 2004 10:49 am

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.

hank
Posts: 31
Joined: Mon May 12, 2003 10:02 am
Location: Lake of Constance, Germany

Post by hank » Fri Apr 02, 2004 11:03 am

Garv,
garv wrote:
hank wrote:IIRC there is no TRACE-Level in log4j.
According to autocompletion in Eclipse, there is ;).
Gee, my eclipse seems to be broken :-(

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.

===================
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.
What, if I have to use JDK 1.3?
See http://nagoya.apache.org/wiki/apachewik ... JDKLogging for more reasons on that.

Cheers

Heinrich

garv
Posts: 127
Joined: Wed Mar 31, 2004 3:44 pm
Location: Amsterdam, The Netherlands

Post by garv » Fri Apr 02, 2004 11:39 am

hank wrote:Garv,
garv wrote:
hank wrote:IIRC there is no TRACE-Level in log4j.
According to autocompletion in Eclipse, there is ;).
Gee, my eclipse seems to be broken :-(

Which classes are you using?
I cant find Level Trace wheter in javap org.apache.log4j.Level nor in javap java.util.logging.Level.
Image

Straight from Log4j-1.2.8.jar...

hank
Posts: 31
Joined: Mon May 12, 2003 10:02 am
Location: Lake of Constance, Germany

Post by hank » Fri Apr 02, 2004 12:12 pm

Garv,
I'm not quoting your nice image, nevertheless I'm not finding any class called Log nor one called LogFactory in my log4j 1.2.7, 1.2.8, 1.3.0alpha.

This confuses me completely ;-)

May it be that there is some wrapping around the log4j Logger?

kind regards
Heinrich

garv
Posts: 127
Joined: Wed Mar 31, 2004 3:44 pm
Location: Amsterdam, The Netherlands

Post by garv » Fri Apr 02, 2004 2:12 pm

D'oh! It's in commons-logging!

hank
Posts: 31
Joined: Mon May 12, 2003 10:02 am
Location: Lake of Constance, Germany

Post by hank » Fri Apr 02, 2004 2:20 pm

garv wrote:D'oh! It's in commons-logging!
ahh, thanks for this solution.

Have a nice and recovering weekend, Garv!

cheers

Heinrich

Locked