Solved

Logging info not appearing in console

Posted on 2007-04-11
10
188 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
login jsp example 24 104
Chrome and Firefox Java 5 88
Glassfish admin console not working 1 88
hashmap order 17 61
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

739 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