Rainy days and Java always get me down


I've Moved My Blog

It's currently located at http://www.urlinone.com/blog

I should say "I'm moving my blog." It's a pretty painful process.

Pebble has blown up on me, and it's been many months since I've been able to blog reliably. I've lost posts. And now I've got to figure out how to migrate my past blog posts from Pebble to my new destination without all the URLs changing, lest external links become 404 Not Founds.

Why does everything in the 21st century have to be a three-day project???

When you try to run a program that does logging from within Eclipse, have you ever seen this:

log4j:WARN No appenders could be found for logger (com.greymatter.MyClass).
log4j:WARN Please initialize the log4j system properly.
This happens because Log4j can't find its .properties file, so it can't configure its appenders, so you don't get any logging information. Here's how to fix this...

  1. In Eclipse, in one of the several places where you can find this, select either Run... or Debug... (Your change will apply to both types of program execution.)
  2. In the tree view on the left, select the Configuration you'd like to run with logging enabled.
  3. Click on the Classpath tab along the top.
  4. Click on the User Entries item in the tree view to select it.
  5. Click the Advanced... button.
  6. Select the Add Classpath Variables radio button, and click OK.
  7. If you see LOG4J_PROPS in the list of variables, select it and click OK. If it is not in the list, click the Configure Variables button. Add a Classpath Variable named LOG4J_PROPS with a value of the absolute path to the folder that contains the log4j.properties file. Once you've completed this process of adding the new variable, you will of course need to select it as you would have done if it had already existed.
  8. Click Apply to save your changes.

That's it! You should now be able to run or debug your app in Eclipse and have log4j configure properly. Ain't life grand?!

Revised January 17, 2005


Thank You !!!! This has been driving my nuts for 3 days...
When I add LOG4J_PROPS, the error message about no appenders goes away, but there is an unwelcome side effect. <pre> Prior to the change, Run... [Test] displays (*) Run a single test Project foo Test class: com.foo.test.Test Test method:testBar </pre> After adding LOG4J_PROPS, the test method goes away. It's not a writeable text-entry field, so I cannot retype the desired method. This causes all tests in the class to run, not just the desired method. Ideas? <p> Also, is there a way to have one LOG4J_PROPS apply as a default to all tests?
How about creating a jar file, say log4jprops.jar, that contains only log4j.properties?<br> <br>Then add log4jprops.jar to your project build path the same way you added log4j.jar
It looks like it's not working with log4j.xml because I keep having the same message. D.
It looks like it's not working with log4j.xml because I keep having the same message. D.
hey dudes. I also had a great problem configuring log4j. I tried creating a jar file with log4j.properties and this works briliantly. Biggest advantage is that the jar file is added 'relatively' to the workspace so that i can easily share my project with other developers.
This does not seem to work if you are using log4j in conjunction with Commons logging...
i don't know what commons logging is for, but my build is definitely using the file 'commons-logging-1.0.4.jar' for something. To test this i renamed it and i ended up with no reporting into the console window in Eclipse 3.1. So i would say i am running it with commons logging of some kind.
Hi, the solution specified by you might work for java projects, but how do i achieve the same in plugin projects. I am using Eclipse and use RCP plugin architecture. There is no classpath as suggested by you in the debug/run configuration for plugin projects. tia -mohit


Add a comment

Title
Body
HTML : b, i, blockquote, br, p, pre, a href="", ul, ol, li
Name
E-mail address
Website
Remember me Yes  No 

E-mail addresses are not publicly displayed, so please only leave your e-mail address if you would like to be notified when new comments are added to this blog entry (you can opt-out later).

TrackBack to http://www.leegrey.com/hmm/addTrackBack.action?entry=1090536124000