[logback-user] Project Can't Find logback.xml file

Roger Spears rspears at northweststate.edu
Sat Jan 21 02:06:43 CET 2012


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

Thanks,
Roger

> Adam Gordon <mailto:adam.n.gordon at gmail.com>
> January 20, 2012 7:44 PM
> based on Tony's earlier response, it sounds like log back still cannot 
> find
> your XML file on the class path.
>
> --adam
>
> On Jan 20, 2012, at 17:41, Roger Spears <rspears at northweststate.edu> 
> wrote:
>
> I'm curious, when you run the attached project, what do you get for the
> console output? Since it has FOOBAR in the pattern, I would have expected
> to see FOOBAR on the console. Instead, I still see the default display:
>
> 19:34:45.088 [main] INFO helloworld.HelloWorld - hello world!
>
> Is that what you get when you the project that you attached?
>
> Thanks,
> Roger
>
> <compose-unknown-contact.jpg>
> Tony Trinh <tony19 at gmail.com>
> January 20, 2012 1:34 PM
> Put logback.xml into the root of your src directory (not in a subdir). 
> This
> worked fine for me (see attached Netbeans project).
>
> The output you were seeing was from the
> BasicConfigurator
> <http://logback.qos.ch/apidocs/ch/qos/logback/classic/BasicConfigurator.html><http://logback.qos.ch/apidocs/ch/qos/logback/classic/BasicConfigurator.html>
> (loaded
> by default when logback.xml is not found in your classpath), which 
> uses the
> ConsoleAppender. It just so happens that your logback.xml also uses the
> same type of appender, which might have confused you into thinking that
> Logback was ignoring the specified pattern in your configuration.
>
>
> On Fri, Jan 20, 2012 at 12:07 PM, Roger Spears
>
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user
> <compose-unknown-contact.jpg>
> Roger Spears <rspears at northweststate.edu>
> January 20, 2012 12:07 PM
> Hello,
>
> I'm running Netbeans 7.0.1 on a Mac Book Pro with OS Lion. I'm currently
> using log4j without any problems. I wanted to try out logback.
>
> Yesterday I downloaded logback and placed the 4 jar files in the proper
> location. I'm able to run the basic logback HelloWorld example. Here's
> the code for the HelloWorld example I'm working with:
>
> package helloworld;
>
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
>
> public class HelloWorld {
>
> public static void main(String[] args) {
>
> Logger logger = LoggerFactory.getLogger("helloworld");
> logger.debug("Hello world.");
>
> }
>
> }
>
> Here's my customized logback.xml file:
>
> <configuration>
> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
> <encoder>
> <pattern>%date %n [%thread] %level %logger{35} - %n %msg</pattern>
> </encoder>
> </appender>
> <root level="DEBUG">
> <appender-ref ref="STDOUT" />
> </root>
> </configuration>
>
> The problem is...Netbeans (or java) never picks up on my customized
> logback.xml file. I'm starting out easy by just changing the pattern to
> see if I can get it to work. When I run the project, I see the following
> on the console:
>
> 11:56:33.569 [main] DEBUG helloworld - Hello world.
>
> That's not the pattern I specified in logback.xml.
>
> I'm assuming I just don't have it in the proper location. I have a copy of
> logback.xml in the following locations just to see if I had it in the 
> wrong
> place:
>
> NetBeansProjects -> HelloWorld -> src -> logback.xml
>
> NetBeansProjects -> HelloWorld -> logback.xml
>
> NetBeansProjects -> HelloWorld -> nbproject -> private -> logback.xml
>
> NetBeansProjects -> HelloWorld -> build -> classes -> logback.xml
>
> System -> Libraries -> Java -> Extensions -> logback.xml
>
>
> I am still unable to get the pattern I'm looking for.
>
> Does anyone know why this would be happening?
>
> Thanks,
> Roger
>
>
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user
> Tony Trinh <mailto:tony19 at gmail.com>
> January 20, 2012 1:34 PM
> Put logback.xml into the root of your src directory (not in a subdir). 
> This
> worked fine for me (see attached Netbeans project).
>
> The output you were seeing was from the
> BasicConfigurator<http://logback.qos.ch/apidocs/ch/qos/logback/classic/BasicConfigurator.html>
> (loaded
> by default when logback.xml is not found in your classpath), which 
> uses the
> ConsoleAppender. It just so happens that your logback.xml also uses the
> same type of appender, which might have confused you into thinking that
> Logback was ignoring the specified pattern in your configuration.
>
>
> On Fri, Jan 20, 2012 at 12:07 PM, Roger Spears
>
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user
> Roger Spears <mailto:rspears at northweststate.edu>
> January 20, 2012 12:07 PM
> Hello,
>
> I'm running Netbeans 7.0.1 on a Mac Book Pro with OS Lion.  I'm 
> currently using log4j without any problems.  I wanted to try out logback.
>
> Yesterday I downloaded logback and placed the 4 jar files in the 
> proper location.  I'm able to run the basic logback HelloWorld 
> example.  Here's the code for the HelloWorld example I'm working with:
>
> package helloworld;
>
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
>
> public class HelloWorld {
>
>   public static void main(String[] args) {
>
>     Logger logger = LoggerFactory.getLogger("helloworld");
>     logger.debug("Hello world.");
>
>   }
>
> }
>
> Here's my customized logback.xml file:
>
> <configuration>
> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
> <encoder>
> <pattern>%date %n [%thread] %level %logger{35} - %n %msg</pattern>
> </encoder>
> </appender>
> <root level="DEBUG">
> <appender-ref ref="STDOUT" />
> </root>
> </configuration>
>
> The problem is...Netbeans (or java) never picks up on my customized 
> logback.xml file.  I'm starting out easy by just changing the pattern 
> to see if I can get it to work.  When I run the project, I see the 
> following on the console:
>
> 11:56:33.569 [main] DEBUG helloworld - Hello world.
>
> That's not the pattern I specified in logback.xml.
>
> I'm assuming I just don't have it in the proper location.  I have a 
> copy of logback.xml in the following locations just to see if I had it 
> in the wrong place:
>
> NetBeansProjects -> HelloWorld -> src -> logback.xml
>
> NetBeansProjects -> HelloWorld -> logback.xml
>
> NetBeansProjects -> HelloWorld -> nbproject -> private -> logback.xml
>
> NetBeansProjects -> HelloWorld -> build -> classes -> logback.xml
>
> System -> Libraries -> Java -> Extensions -> logback.xml
>
>
> I am still unable to get the pattern I'm looking for.
>
> Does anyone know why this would be happening?
>
> Thanks,
> Roger
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20120120/3e3bee1c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: postbox-contact.jpg
Type: image/jpeg
Size: 1251 bytes
Desc: not available
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20120120/3e3bee1c/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compose-unknown-contact.jpg
Type: image/jpeg
Size: 770 bytes
Desc: not available
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20120120/3e3bee1c/attachment-0001.jpg>


More information about the Logback-user mailing list