Mary, If you decide to try log4j-2.0 (heartily recommended), the config file name should be log4j2.xml.
The 2.0 site also has many example configs in the manual pages. And we'd love your feedback. :-) Remko Sent from my iPhone On 2013/05/14, at 10:44, Gary Gregory <[email protected]> wrote: > Yes, sorry about that, I am in 2.0 mode. > > Gary > > On May 13, 2013, at 21:41, Remko Popma <[email protected]> wrote: > >> Mary, >> >> Gary was referring to log4j-2.0. While generally more awesome (ahem), it >> does need those 2 jars to run. >> >> You seem to be using log4j-1.2. >> Then you should only need the one jar. >> You also need a log4j.properties or log4j.xml file in a directory that is in >> the classpath. The site should have some sample config files. >> >> In your code, I don't think you need to call BasicConfigurator.configure(); >> I think you can safely remove that line; log4j will pick up your config file >> from the classpath. >> >> Sent from my iPhone >> >> On 2013/05/14, at 10:30, Mary Laude <[email protected]> wrote: >> >>> Hey - thanks for the quick reply! Ya know, I read that bit >>> but the jar file I have is named log4j-1.2-17.jar, and I thought >>> it comprised everything. When I downloaded the code, that's >>> the only jar file there was. Clearly, I was delusional! I'll go >>> look for the corresponding API and core jar files... >>> Thanks again! >>> >>> >>> >>> On Mon, May 13, 2013 at 6:00 PM, Gary Gregory <[email protected]>wrote: >>> >>>> You need the API and core jar files on your classpath for compilation >>>> and runtime. >>>> >>>> Gary >>>> >>>> On May 13, 2013, at 20:46, Mary Laude <[email protected]> wrote: >>>> >>>>> Hello - >>>>> >>>>> I can write, compile, and successfully run a Java program >>>>> to look at a .jar file and list the classes defined therein, but >>>>> I can't for the life of me get your "Using log4j" java code shown >>>>> in 1-2.17's INSTALL doc to work. >>>>> >>>>> Perhaps there's some other magic that needs to happen to get >>>>> this code snippet you wrote to yield output? >>>> ---------------------------------------------------------------------------------------- >>>>> You can now test your installation by first compiling the following >>>>> simple program. >>>>> >>>>> import org.apache.log4j.Logger; >>>>> import org.apache.log4j.BasicConfigurator; >>>>> >>>>> public class Hello { >>>>> >>>>> private static final Logger logger = Logger.getLogger(Hello.class); >>>>> >>>>> public >>>>> static >>>>> void main(String argv[]) { >>>>> BasicConfigurator.configure(); >>>>> logger.debug("Hello world."); >>>>> logger.info("What a beatiful day."); >>>>> } >>>>> } >>>> ----------------------------------------------------------------------------------------- >>>>> I understand how CLASSPATH works, etc. I can get it to compile but >>>>> even if I again (with option -cp) specify exactly where the .class file >>>> is >>>>> that it just created from the compile, it still can't find what it needs. >>>>> >>>>> Depending on where I've put things and what I tell it, I get one of these >>>>> failing results when I try to run the executable: >>>>> >>>>> (1) >>>>> java.lang.NoClassDefFoundError: org/apache/log4j/Logger >>>>> at Hello.<clinit>(Hello.java:6) >>>>> Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger >>>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:366) >>>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:355) >>>>> at java.security.AccessController.doPrivileged(Native Method) >>>>> at java.net.URLClassLoader.findClass(URLClassLoader.java:354) >>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:423) >>>>> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) >>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:356) >>>>> ... 1 more >>>>> Exception in thread "main" >>>>> >>>>> or (2) >>>>> Error: Could not find or load main class Hello >>>>> >>>>> >>>>> Please, I am an old UNIX geek but this is really really frustrating me. >>>>> I have looked literally EVERYWHERE to find out what the problem is >>>>> but of course I am apparently the first and only person to ever have this >>>>> problem. Ha! >>>>> >>>>> >>>>> -- >>>>> Please test what you build. >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: [email protected] >>>> For additional commands, e-mail: [email protected] >>> >>> >>> -- >>> Please test what you build. >> >> --------------------------------------------------------------------- >> 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]
