Project Can't Find logback.xml file

View: New views
13 Messages — Rating Filter:   Alert me  

Project Can't Find logback.xml file

by Roger Spears :: Rate this Message:

| View Threaded | Show Only this Message

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
--
Roger

_______________________________________________
Logback-user mailing list
Logback-user@...
http://mailman.qos.ch/mailman/listinfo/logback-user

Re: Project Can't Find logback.xml file

by Adam Gordon :: Rate this Message:

| View Threaded | Show Only this Message

The XML file needs to be in your class path.  The first thing I would check is to see if you can load the file as a resource with ClassLoader.getResourceAsStream(String) or similar.  If this is able to load the file, then it's on your class path and I'm not sure what the problem is but it's something to eliminate as an issue first.

In my maven project, I have it in src/main/resources and everything is happy.

On Jan 20, 2012, at 10:07 AM, Roger Spears wrote:

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
--
Roger
_______________________________________________
Logback-user mailing list
Logback-user@...
http://mailman.qos.ch/mailman/listinfo/logback-user


_______________________________________________
Logback-user mailing list
Logback-user@...
http://mailman.qos.ch/mailman/listinfo/logback-user

Re: Project Can't Find logback.xml file

by Roger Spears :: Rate this Message:

| View Threaded | Show Only this Message

Hello,

Thank you for your suggestion of add the ClassLoader.  I don't know why I didn't think of that.  Maybe it's because I'm fairly new to Java.

I added the following two lines to my HelloWorld.java class:

    String URL = "logback.xml";
    System.out.println(ClassLoader.getSystemResource(URL));

The output I receive on the console looks like this:

file:/Users/roger/NetBeansProjects/HelloWorld/build/classes/logback.xml
12:30:01.762 [main] DEBUG helloworld - Hello world.

When I open the logback.xml file that is listed in the console output, it looks exactly like the custom logback.xml file I created.

The problem still exists that it's not picking up on the custom pattern I have in logback.xml.  That pattern looks like this:

<pattern>%date %n [%thread] %level %logger{35} - %n %msg</pattern>


I would have expected to see the date followed by a jump down to a new line followed by [main] followed by a jump down to a new line and etc. etc etc.

Am I wrong to think logback uses %n as new line characters?

My experience has been with log4j and %n generates the newline in its pattern.

Thanks again,
Rogert

January 20, 2012 12:13 PM
The XML file needs to be in your class path. The first thing I would check is to see if you can load the file as a resource with ClassLoader.getResourceAsStream(String) or similar. If this is able to load the file, then it's on your class path and I'm not sure what the problem is but it's something to eliminate as an issue first.

In my maven project, I have it in src/main/resources and everything is happy.



_______________________________________________
Logback-user mailing list
Logback-user@...
http://mailman.qos.ch/mailman/listinfo/logback-user
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@...
http://mailman.qos.ch/mailman/listinfo/logback-user

Re: Project Can't Find logback.xml file

by Adam Gordon :: Rate this Message:

| View Threaded | Show Only this Message

I'm no logback expert either… :-)

No, you're right.  %n is a newline.  The space character beforehand is not necessary but it shouldn't cause any issues.  See http://logback.qos.ch/manual/layouts.html for details on pattern characters (what they are, how to use them, etc…)

I don't know if it will make any difference - as I don't know what the default encoder is if you don't specify one, but try setting the class attribute on your <encoder> element, i.e.:

<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
  <pattern>….</pattern>
</encoder>

You may also want to try changing the pattern to see if the changes are indeed picked up.  I don't see any package in front of your class, but this may be due to the class being in the default package.

On Jan 20, 2012, at 10:42 AM, Roger Spears wrote:

Hello,

Thank you for your suggestion of add the ClassLoader.  I don't know why I didn't think of that.  Maybe it's because I'm fairly new to Java.

I added the following two lines to my HelloWorld.java class:

    String URL = "logback.xml";
    System.out.println(ClassLoader.getSystemResource(URL));

The output I receive on the console looks like this:

file:/Users/roger/NetBeansProjects/HelloWorld/build/classes/logback.xml
12:30:01.762 [main] DEBUG helloworld - Hello world.

When I open the logback.xml file that is listed in the console output, it looks exactly like the custom logback.xml file I created.

The problem still exists that it's not picking up on the custom pattern I have in logback.xml.  That pattern looks like this:

<pattern>%date %n [%thread] %level %logger{35} - %n %msg</pattern>


I would have expected to see the date followed by a jump down to a new line followed by [main] followed by a jump down to a new line and etc. etc etc.

Am I wrong to think logback uses %n as new line characters?

My experience has been with log4j and %n generates the newline in its pattern.

Thanks again,
Rogert

January 20, 2012 12:13 PM
The XML file needs to be in your class path. The first thing I would check is to see if you can load the file as a resource with ClassLoader.getResourceAsStream(String) or similar. If this is able to load the file, then it's on your class path and I'm not sure what the problem is but it's something to eliminate as an issue first.

In my maven project, I have it in src/main/resources and everything is happy.



_______________________________________________
Logback-user mailing list
Logback-user@...
http://mailman.qos.ch/mailman/listinfo/logback-user
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@...
http://mailman.qos.ch/mailman/listinfo/logback-user




_______________________________________________
Logback-user mailing list
Logback-user@...
http://mailman.qos.ch/mailman/listinfo/logback-user

Re: Project Can't Find logback.xml file

by tony19 :: Rate this Message:

| View Threaded | Show Only this Message

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 (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 <rspears@...> wrote:
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
--
Roger

_______________________________________________
Logback-user mailing list
Logback-user@...
http://mailman.qos.ch/mailman/listinfo/logback-user



_______________________________________________
Logback-user mailing list
Logback-user@...
http://mailman.qos.ch/mailman/listinfo/logback-user

HelloWorld.tgz (14K) Download Attachment

Re: Project Can't Find logback.xml file

by Roger Spears :: Rate this Message:

| View Threaded | Show Only this Message

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
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@...
http://mailman.qos.ch/mailman/listinfo/logback-user
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

--
Roger Spears
Training Coordinator
Northwest State Community College
22600 State Route 34
Archbold, Ohio  43502
P: 419-267-1304
F: 419-267-3891

*********************
These records are protected by the Family Educational Rights and Privacy Act  (FERPA) and are provided under an exception to the Act found in Section 99.32.  These records must be maintained confidentially and may not be re disclosed.  They must be destroyed when your legitimate educational interest no longer exists. If you are not the intended recipient you are hereby notified that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this email transmission in error, please notify me by telephone or via return email and delete this email from your system.

http://www2.ed.gov/policy/gen/reg/ferpa/index.html


_______________________________________________
Logback-user mailing list
Logback-user@...
http://mailman.qos.ch/mailman/listinfo/logback-user

Re: Project Can't Find logback.xml file

by Adam Gordon :: Rate this Message:

| View Threaded | Show Only this Message

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@...> 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>
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@...
http://mailman.qos.ch/mailman/listinfo/logback-user
<compose-unknown-contact.jpg>
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

--
Roger Spears
Training Coordinator
Northwest State Community College
22600 State Route 34
Archbold, Ohio  43502
P: 419-267-1304
F: 419-267-3891

*********************
These records are protected by the Family Educational Rights and Privacy Act  (FERPA) and are provided under an exception to the Act found in Section 99.32.  These records must be maintained confidentially and may not be re disclosed.  They must be destroyed when your legitimate educational interest no longer exists. If you are not the intended recipient you are hereby notified that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this email transmission in error, please notify me by telephone or via return email and delete this email from your system.

http://www2.ed.gov/policy/gen/reg/ferpa/index.html
_______________________________________________
Logback-user mailing list
Logback-user@...
http://mailman.qos.ch/mailman/listinfo/logback-user

_______________________________________________
Logback-user mailing list
Logback-user@...
http://mailman.qos.ch/mailman/listinfo/logback-user

Re: Project Can't Find logback.xml file

by Roger Spears :: Rate this Message:

| View Threaded | Show Only this Message

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

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@... 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@...
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@...
http://mailman.qos.ch/mailman/listinfo/logback-user
<compose-unknown-contact.jpg>
Roger Spears rspears@...
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@...
http://mailman.qos.ch/mailman/listinfo/logback-user
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@...
http://mailman.qos.ch/mailman/listinfo/logback-user
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@...
http://mailman.qos.ch/mailman/listinfo/logback-user

Re: Project Can't Find logback.xml file

by tony19 :: Rate this Message:

| View Threaded | Show Only this Message

See below...

On Fri, Jan 20, 2012 at 8:06 PM, Roger Spears <rspears@...> 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:

run:
2012-01-20 21:10:50,277 
 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.



_______________________________________________
Logback-user mailing list
Logback-user@...
http://mailman.qos.ch/mailman/listinfo/logback-user

Re: Project Can't Find logback.xml file

by Roger Spears :: Rate this Message:

| View Threaded | Show Only this Message

Thank you for the suggestion....Unfortunately, I get the same result....

09:49:47.151 [main] INFO  logtest.LogTest - hello world


I followed your directions with the exception of naming the class HelloWorld.  I named it LogTest.

When I right clicked on Source Package and added new xml file, Netbeans created the <default package> folder on its own.


I'm attaching two screen shots of my netbeans setup. 

The first screen shot is LogTest.java and the second is logback.xml.

Thanks,
Roger




_______________________________________________
Logback-user mailing list
Logback-user@...
http://mailman.qos.ch/mailman/listinfo/logback-user

logtest.png (130K) Download Attachment
logback.png (105K) Download Attachment

Re: Project Can't Find logback.xml file

by tony19 :: Rate this Message:

| View Threaded | Show Only this Message

You might not have noticed that your file is named "logback.xml.xml" (with the extra .xml extension). Try renaming that file to "logback.xml", and then run it again.

On Mon, Jan 23, 2012 at 9:57 AM, Roger Spears <rspears@...> wrote:
Thank you for the suggestion....Unfortunately, I get the same result....

09:49:47.151 [main] INFO  logtest.LogTest - hello world


I followed your directions with the exception of naming the class HelloWorld.  I named it LogTest.

When I right clicked on Source Package and added new xml file, Netbeans created the <default package> folder on its own.


I'm attaching two screen shots of my netbeans setup. 

The first screen shot is LogTest.java and the second is logback.xml.

Thanks,
Roger

_______________________________________________
Logback-user mailing list
Logback-user@...
http://mailman.qos.ch/mailman/listinfo/logback-user

Re: Project Can't Find logback.xml file

by tony19 :: Rate this Message:

| View Threaded | Show Only this Message

Also, your logback.xml is missing a closing bracket for </configuration>.

On Mon, Jan 23, 2012 at 11:01 AM, Tony Trinh <tony19@...> wrote:
You might not have noticed that your file is named "logback.xml.xml" (with the extra .xml extension). Try renaming that file to "logback.xml", and then run it again.


_______________________________________________
Logback-user mailing list
Logback-user@...
http://mailman.qos.ch/mailman/listinfo/logback-user

Re: Project Can't Find logback.xml file

by Roger Spears :: Rate this Message:

| View Threaded | Show Only this Message

Hello,

Good catches!  That was a little bit embarrassing to say the least.

Unfortunately, I still get the standard response on my console:

11:09:20.731 [main] INFO  logtest.LogTest - hello world


Also, I'm including two screen shots with this email.  The first is a shot of the corrected xml code.  The second is a list of what's in my library for this project.  Maybe there's something there/not there that I can correct?.?.



January 23, 2012 11:04 AM
Also, your logback.xml is missing a closing bracket for </configuration*>*.


_______________________________________________
Logback-user mailing list
Logback-user@...
http://mailman.qos.ch/mailman/listinfo/logback-user
January 23, 2012 11:01 AM
You might not have noticed that your file is named "logback.xml*.xml*"
(with the extra .xml extension). Try renaming that file to "logback.xml",
and then run it again.


_______________________________________________
Logback-user mailing list
Logback-user@...
http://mailman.qos.ch/mailman/listinfo/logback-user
January 23, 2012 9:57 AM
Thank you for the suggestion....Unfortunately, I get the same result....

09:49:47.151 [main] INFO  logtest.LogTest - hello world


I followed your directions with the exception of naming the class HelloWorld.  I named it LogTest.

When I right clicked on Source Package and added new xml file, Netbeans created the <default package> folder on its own.


I'm attaching two screen shots of my netbeans setup.

The first screen shot is LogTest.java and the second is logback.xml.

Thanks,
Roger


January 20, 2012 9:27 PM
See below...

On Fri, Jan 20, 2012 at 8:06 PM, Roger Spears rspears@...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:

run:
2012-01-20 21:10:50,277
 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.

_______________________________________________
Logback-user mailing list
Logback-user@...
http://mailman.qos.ch/mailman/listinfo/logback-user
January 20, 2012 8:06 PM
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 adam.n.gordon@...
> 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@... 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@...
> 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@...
> http://mailman.qos.ch/mailman/listinfo/logback-user
> <compose-unknown-contact.jpg>
> Roger Spears rspears@...
> 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@...
> http://mailman.qos.ch/mailman/listinfo/logback-user
> Tony Trinh tony19@...
> 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@...
> http://mailman.qos.ch/mailman/listinfo/logback-user
> Roger Spears rspears@...
> 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

--
Roger Spears
Training Coordinator
Northwest State Community College
22600 State Route 34
Archbold, Ohio  43502
P: 419-267-1304
F: 419-267-3891

*********************
These records are protected by the Family Educational Rights and Privacy Act  (FERPA) and are provided under an exception to the Act found in Section 99.32.  These records must be maintained confidentially and may not be re disclosed.  They must be destroyed when your legitimate educational interest no longer exists. If you are not the intended recipient you are hereby notified that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this email transmission in error, please notify me by telephone or via return email and delete this email from your system.

http://www2.ed.gov/policy/gen/reg/ferpa/index.html




_______________________________________________
Logback-user mailing list
Logback-user@...
http://mailman.qos.ch/mailman/listinfo/logback-user

CorrectedCode.png (101K) Download Attachment
LogBackLibrary.png (79K) Download Attachment