Solved

Logging info not appearing in console

Posted on 2007-04-11
10
185 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
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 …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now