[jboss-user] [Beginner's Corner] - Problems with LogFactory.getLog(String)

SkyMe do-not-reply at jboss.com
Wed Sep 30 04:13:30 EDT 2009

I faced with a problem using LogFactory.getLog for logging.
I configure my log4j with DOMConfigurator.configureAndWatch(XMLFile) and then I create an instance of commons.logging.Log
Log log = LogFactory.getLog(className);
After that I try to log:
log.info("I'm a log!");
XMLFile configure log4j to write logs to file (see below).
but the last command writes logs to the specified file and to CONSOLE. Why?

and two more things:
- I've included log4j.jar to the lib of my .ear project - with this I wanted all my project to use one log4j configuration.
- This all is under JBoss AS. And I don't want to use xml file of jboss to configure log4j.

This is my xml config file:

  | <?xml version="1.0" encoding="UTF-8"?>
  | <!DOCTYPE log4j:configuration >
  | <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
  |    <appender name="fileappender" class="org.apache.log4j.DailyRollingFileAppender">
  |       <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
  |       <param name="File" value="${jboss.server.home.dir}/log/project.log"/>
  |       <param name="Append" value="true"/>
  |       <param name="DatePattern" value="'.'yyyy-MM-dd"/>
  |       <layout class="org.apache.log4j.PatternLayout">
  |          <param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n"/>
  |       </layout>
  |    </appender>
  |    <category name="some.package">
  |       <priority value="DEBUG" />
  |       <appender-ref ref="fileappender" />
  |    </category>
  | </log4j:configuration>

Thank you!

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4257800#4257800

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4257800

More information about the jboss-user mailing list