Solved

Logging info not appearing in console

Posted on 2007-04-11
10
184 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
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 …

746 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

9 Experts available now in Live!

Get 1:1 Help Now