Solved

Logging info not appearing in console

Posted on 2007-04-11
10
186 Views
Last Modified: 2010-03-31
Hi,

If log is not null(log: org.apache.commons.logging.impl.Log4JLogger@11e67ac), but I don't see any log info in console.        
    ...
...  
               Log log = LogFactory.getLog(target.getClass());
               System.out.println("log: " + log);
               log.trace("Executing method: " + method.getName() + " " + target.getClass());
               log.info("Executing method: " + method.getName() + " " + target.getClass());
...
...

What am I doing wrong?

thx
0
Comment
Question by:dkim18
  • 3
  • 2
  • 2
  • +1
10 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 18890387
Please post your log config file
0
 

Author Comment

by:dkim18
ID: 18890494
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
      threshold="all" debug="false">
 <!--
       STDOUT                              
      <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
            <param name="Target" value="System.out" />
            <layout class="org.apache.log4j.PatternLayout">
                  <param name="ConversionPattern"
                        value="[%d{ISO8601}] %-5p %c %m %n" />
            </layout>
            <filter class="org.apache.log4j.varia.LevelRangeFilter">
                  <param name="LevelMin" value="DEBUG" />
                  <param name="LevelMax" value="INFO" />
            </filter>
      </appender>


       STDERR                              
      <appender name="STDERR" class="org.apache.log4j.ConsoleAppender">
            <param name="Target" value="System.err" />
            <layout class="org.apache.log4j.PatternLayout">
                  <param name="ConversionPattern"
                        value="[%d{ISO8601}] %-5p %c %m %n" />
            </layout>
            <filter class="org.apache.log4j.varia.LevelRangeFilter">
                  <param name="LevelMin" value="WARN" />
                  <param name="LevelMax" value="FATAL" />
            </filter>
      </appender>

    -->

      <logger name="org.springframework">
            <level value="INFO" />
      </logger>

<!--
      <logger name="ch">
            <level value="DEBUG" />
      </logger>
    -->
      <!--                           -->
      <!-- setup log4j's root logger -->
      <!--                           -->
      <root>
            <level value="all" />
            <appender-ref ref="STDOUT" />
            <appender-ref ref="STDERR" />

      </root>

</log4j:configuration>
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 18890597
Try

Log log = LogFactory.getLog("STDOUT");
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:dkim18
ID: 18890725
Log log = LogFactory.getLog("STDOUT");
log.trace("Executing method: " + method.getName() + " " + target.getClass());
log.info("Executing method: " + method.getName() + " " + target.getClass());

didn't print anything...
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 84 total points
ID: 18890771
What's your config file called and where is it? Do you get any errors reported in the console?
0
 
LVL 92

Assisted Solution

by:objects
objects earned 83 total points
ID: 18894201
both your appenders are commented out
0
 
LVL 12

Assisted Solution

by:keyurkarnik
keyurkarnik earned 83 total points
ID: 18904137
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
      threshold="all" debug="false">
                         
      <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
            <param name="Target" value="System.out" />
            <layout class="org.apache.log4j.PatternLayout">
                  <param name="ConversionPattern"
                        value="[%d{ISO8601}] %-5p %c %m %n" />
            </layout>
            <filter class="org.apache.log4j.varia.LevelRangeFilter">
                  <param name="LevelMin" value="DEBUG" />
                  <param name="LevelMax" value="INFO" />
            </filter>
      </appender>

                           
      <appender name="STDERR" class="org.apache.log4j.ConsoleAppender">
            <param name="Target" value="System.err" />
            <layout class="org.apache.log4j.PatternLayout">
                  <param name="ConversionPattern"
                        value="[%d{ISO8601}] %-5p %c %m %n" />
            </layout>
            <filter class="org.apache.log4j.varia.LevelRangeFilter">
                  <param name="LevelMin" value="WARN" />
                  <param name="LevelMax" value="FATAL" />
            </filter>
      </appender>


      <logger name="org.springframework">
            <level value="INFO" />
      </logger>


      <!--                           -->
      <!-- setup log4j's root logger -->
      <!--                           -->
      <root>
            <level value="all" />
            <appender-ref ref="STDOUT" />
            <appender-ref ref="STDERR" />

      </root>

</log4j:configuration>


OR

just create a new log4j.properties and put in this :

log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{DATE} - %p %c - %m%n

log4j.rootLogger=DEBUG, CONSOLE



0
 
LVL 12

Expert Comment

by:keyurkarnik
ID: 18904146
You can also get the logger as :

Logger logger = Logger.getLogger("your.log.name.here");

If the logger is found, it will take the specific logger, or just use the root logger
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question