See below...
On Fri, Jan 20, 2012 at 8:06 PM, Roger Spears
<rspears@northweststate.edu> wrote:
I also tried adding the
class to the encoder. That didn't work either.
Something else that's weird. I imported Tony's project to my Netbeans
and it stated it had reference issues. It could not find
logback-core-1.0.0.jar, logback-classic-1.0.0.jar and
sl4j-api-1.6.4.jar. I know I can resolve this, I'll just point them
towards my versions of those jar's. BUT, for giggles, I ran the project
with the unresolved reference issues and it displayed the same thing on
the console:
19:57:35.609 [main] INFO helloworld.HelloWorld - hello world!
I just imported that project into another machine, updated the JAR references (as they're not in the same location on the other machine), and ran it. I see this:
FOOBAR [main] INFO helloworld.HelloWorld -
hello world!BUILD SUCCESSFUL (total time: 0 seconds)
I'm not sure if that's a clue to anything or if that's the expected
behavior since I have those files in my classpath.
Try my exact steps to create that project:
1. Create a new Java project in Netbeans (or Eclipse...same steps here work).
2. Create a class named "HelloWorld", and copy this code into it:
package helloworld;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HelloWorld {
private static final Logger LOG = LoggerFactory.getLogger(HelloWorld.class);
public static void main(String[] args) {
LOG.info("hello world!");
}
}
3. Create a file named logback.xml in the src directory (do not put it under src/helloworld or any other subdirectory). Copy the following into the file:
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%date %n FOOBAR [%thread] %level %logger{35} - %n %msg</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="STDOUT" />
</root>
</configuration>
You can actually put logback.xml into any directory specified by the run.classpath property in ${project.dir}/nbproject/project.properties. We used src here only because it's quick and easy.
4. Build and run the project.