You're right that my approach isn't guaranteed to work in the general case -- many applications either use dynamic classloading internally or resources in their jars. For example, this often takes the form of a property file in the jar which maps plugin names to plugin classes. And those classes will not show up via a compile. In stead, you'll get a ClassNotFoundException at runtime.
But log4j doesn't appear to do this anywhere, so we just need to compile the classes we actually directly use ourselves and let javac do the work of finding their compile-time dependencies. And for the most part, you can iteratively do the same thing with libs that use classloading internally by adding classes for which we get ClassNotFoundExceptions to the javac command-line. --Ian --- Robert Pepersack <[EMAIL PROTECTED]> wrote: > This approach will work, but you have to make sure that your > application > runs without throwing exceptions. I've done this with my client-side > > Sybase EAServer classes (the jar files for these classes add up to > more > than 10 MB), and found that just compiling is not a guarantee that > the code > will run correctly. > > Bob > > > At 07:33 AM 04/27/2004 -0700, you wrote: > >I have an app that I'm shipping which includes only a subset of > log4j > >1.2.8. I'm only using the basic file and console logging > capabilities > >of log4j, and the classes I'm including from the log4j jar are: > > > >org/apache/log4j/config/*.class > >org/apache/log4j/helpers/*.class > >org/apache/log4j/or/*.class > >org/apache/log4j/spi/*.class > >org/apache/log4j/*.class > > > >This reduces the jar-file from 344k to 115k. And actually we've > >reduced it further -- we eliminated the PropertyGetter and > >PropertyPrinter stuff in the config directory, the syslog stuff in > the > >helpers directory, several of the appenders and layouts we're not > using > >in the log4j package, and one or two random classes in the spi, or > and > >helpers directories. > > > >One way you can tell what classes you really need to ship is to do a > >javac in a clean log4j source directory that compiles Logger.java > and > >all the appenders, filters, and layout classes you're using in your > >config files. The classes that actually get compiled are the ones > you > >need. > > > >--Ian > > > > > >--- Ralf Beger <[EMAIL PROTECTED]> wrote: > > > Hi Yoav, > > > > > > To figure out how much memory is used by log4j, I wrote a small > test > > > application, creating a window frame, contains a scroll table, > some > > > labels and several Buttons connected with listeners etc. > > > The log4j I used with two appenders: console and rolling file, > both > > > with > > > different pattern layout. > > > > > > I�ve build three different versions of this test application, > > > 1) naked, > > > 2) with System.out.println(), > > > 3) with log4j � one logger.info() replaces one println(), > > > > > > I calculated the number of inserted code lines versus the amount > and > > > ratio of bytes have increased the class files. > > > > > > Here are the results of my investigations: > > > > > > Test Application: 1) naked 2) println() 3) > logging() > > > total Code lines: 420 435 440 > > > print/log Code lines: 0 15 20 > > > total class bytes: 17118 18054 18892 > > > code line ratio: - 3,4 % 4,5 % > > > class byte ratio: - 5,5 % 10,4 % > > > > > > Conclusion: > > > Replacing legacy System.out.println() by logging with log4j > doubles > > > the > > > amount of memory used in addition to a naked (non traced) > > > application. > > > In other words, if one application uses 10 % of its code for > > > System.out.println(), its amount in bytes will increase 10 % when > > > replaced by log4j. > > > > > > So if we were stingy logging, it wouldn�t burst our system. > > > But the library log4j-1.2.8.jar could be too big for us. > > > Is it possible to simply remove unused classes - as for instance > xml > > > - > > > from the library to slim it? > > > > > > Thanks, > > > Ralf > > > > > > > > > Shapira, Yoav schrieb: > > > > Hi, > > > > I don't know, but it wouldn't be difficult to track with a > > > profiler, and > > > > then please post the results to the list as I'm sure others are > > > curious > > > > ;) > > > > > > > > Yoav Shapira > > > > Millennium Research Informatics > > > > > > > > > > > > > > > >>-----Original Message----- > > > > > > > > From: Ralf Beger [mailto:[EMAIL PROTECTED] > > > > > > > >>Sent: Wednesday, April 14, 2004 11:16 AM > > > >>To: [EMAIL PROTECTED] > > > >>Subject: How big is log4j? > > > >> > > > >>How big is log4j? > > > >> > > > >>I'm looking for a logging tool in embedded systems. > > > >>The performance of log4j would meet our expectations. > > > >>We want to use log4j in a mid extent > > > >>(up to 3 Appenders: console, file, syslogd). > > > >>But how much memory needs log4j, once compiled with an > application. > > > >> > > > >>Kind regards, Ralf > > > >> > > > > > > >>--------------------------------------------------------------------- > > > >>To unsubscribe, e-mail: > [EMAIL PROTECTED] > > > >>For additional commands, e-mail: > [EMAIL PROTECTED] > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: > [EMAIL PROTECTED] > > > > > > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > > Bob Pepersack > 410-468-2054 > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
