JBoss Community

Re: JBoss Developer Studio 5 - console log output gone with "Run as Java Application" and using org.apache.commons.logging.LogFactory

created by b.b. in JBoss Tools - View the full discussion

//Here is a Java class to test this.

 

////////////////////////////////////////////////////////////////

import org.apache.commons.logging.Log;

import org.apache.commons.logging.LogFactory;

import org.apache.log4j.Logger;

 

 

public class LoggerTest {

 

          static Log logF = LogFactory.getLog(LoggerTest.class);

 

          static Logger logJ = Logger.getLogger(LoggerTest.class);

 

 

          public static void main(String[] args) {

 

                    System.out.println("LogFactory loggin");

  logF.info("LogFactory?");

  logF.debug("LogFactory");

  logF.error("LogFactory");

                    System.out.println("LogFactory loggin end");

 

                    System.out.println("Logger loggin");

                    logJ.info("Logger");

                    logJ.debug("Logger");

                    logJ.error("Logger");

                    System.out.println("Logger loggin end");

 

          }

 

}

////////////////////////////////////////////////////////////////

 

 

#Content of the file log4j.properties:

 

 

log4j.rootCategory=DEBUG, CONSOLE

 

# Stdout

log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender

log4j.appender.CONSOLE.Threshold=DEBUG

log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout

log4j.appender.CONSOLE.layout.ConversionPattern=[%d{hh:mm:ss.SSS}]%5p - %C.%M:%L - %m  %n

 

 

// the structure of the project for the test

https://community.jboss.org/servlet/JiveServlet/downloadImage/2-755651-19289/272-128/TestLogging.jpg

 

My console output is:

 

LogFactory loggin

LogFactory loggin end

Logger loggin

[07:50:22.099] INFO - LoggerTest.main:25 - Logger

[07:50:22.103]DEBUG - LoggerTest.main:26 - Logger

[07:50:22.104]ERROR - LoggerTest.main:27 - Logger

Logger loggin end

Reply to this message by going to Community

Start a new discussion in JBoss Tools at Community