[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Logging info not appearing in console

Posted on 2007-04-11
10
Medium Priority
?
191 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 336 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 332 total points
ID: 18894201
both your appenders are commented out
0
 
LVL 12

Assisted Solution

by:keyurkarnik
keyurkarnik earned 332 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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn different types of Android Layout and some basics of an Android App.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.
Suggested Courses

650 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