You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by 流子℡ <41...@qq.com> on 2013/09/09 13:59:40 UTC
回复: why can log4j2 not print on console in command window
when i remove log4j-over-slf4j-1.7.5.jar .the command line print the third party log,e.g.
九月 09, 2013 6:50:39 下午 org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@535e27: startup date [Mon Sep 09 18:50:39 CST 2013]; root of context hierarchy
九月 09, 2013 6:50:39 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [spring-config.xml]
I find in the class named AbstractApplicationContext ,the log class is as follows:
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Log logger = LogFactory.getLog(getClass());
and my log classes is as follows:
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
private static final Logger logger = LoggerFactory.getLogger(OOXX.class);
however ,my project's message still can't be printed.
------------------ 原始邮件 ------------------
发件人: "Remko Popma";<re...@gmail.com>;
发送时间: 2013年9月9日(星期一) 上午6:26
收件人: "Log4J Users List"<lo...@logging.apache.org>;
主题: Re: why can log4j2 not print on console in command window
If you have log4j-slf4j-impl-2.0-beta8.jar then I believe you don't
need log4j-over-slf4j-1.7.5.jar
(isn't this jar for log4j-1.2?) Can you remove it and try again?
On Monday, September 9, 2013, 流子℡ <41...@qq.com> wrote:
> I have use the version beta 8 for log4j2, I have third-party framework
> using in my project ,e.g. spring which using slf4j.
> and i import the jars into my libaray :log4j-over-slf4j-1.7.5.jar
> log4j-api-2.0-beta8.jar log4j-core-2.0-beta8.jar
> log4j-slf4j-impl-2.0-beta8.jar
>
>
> and my java environment is JDK 7,my configration file named log4j2.xml is
> as following :
> <?xml version="1.0" encoding="UTF-8"?><!-- status=debug 可以查看log4j的装配过程
> --><configuration status="off" monitorInterval="30"> <properties>
> <property name="LOG_HOME">/log/fish</property> <!-- 日志备份目录
> --> <property name="BACKUP_HOME">{LOG_HOME}/backup</property>
> <property name="STAT_NAME">stat</property> <property
> name="SERVER_NAME">global</property> </properties> <appenders>
> <!-- 定义控制台输出 --> <Console name="Console"
> target="SYSTEM_OUT"> <PatternLayout
> pattern="%date{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread][%file:%line] -
> %msg%n" /> </Console> <!-- 程序员调试日志 -->
> <FastRollingFile name="DevLog" fileName="${LOG_HOME}/${SERVER_NAME}"
>
> filePattern="${LOG_HOME}/${SERVER_NAME}.%d{yyyy-MM-dd-HH}.log">
> <PatternLayout pattern="%date{yyyy-MM-dd HH:mm:ss.SSS} %level
> [%thread][%file:%line] - %msg%n" /> <Policies>
> <TimeBasedTriggeringPolicy interval="1"
> modulate="true" /> </Policies>
> </FastRollingFile> <!-- 游戏产品数据分析日志 -->
> <FastRollingFile name="ProductLog"
> fileName="${LOG_HOME}/${SERVER_NAME}_${STAT_NAME}"
> filePattern="${LOG_HOME}/${SERVER_NAME}_${STAT_NAME}.%d{yyyy-MM-dd-HH}.log">
> <PatternLayout
> pattern="%date{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread][%file:%line] -
> %msg%n" /> <Policies>
> <TimeBasedTriggeringPolicy interval="1"
> modulate="true" /> </Policies>
> </FastRollingFile> </appenders> <loggers> <!--
> 3rdparty Loggers --> <logger name="org.springframework.core"
> level="info"> </logger> <logger
> name="org.springframework.beans" level="info"> </logger>
> <logger name="org.springframework.context" level="info">
> </logger> <logger name="org.springframework.web"
> level="info"> </logger> <logger
> name="org.jboss.netty" level="warn"> </logger>
> <logger name="org.apache.http" level="warn"> </logger>
> <!-- Game Stat logger --> <logger
> name="com.u9.global.service.log" level="info"
> additivity="false"> <appender-ref ref="ProductLog" />
> </logger> <!-- Root Logger --> <root
> level="DEBUG"> <appender-ref ref="DevLog" />
> <appender-ref ref="Console" /> </root>
> </loggers></configuration>
>
> when I run my project ,it works ok in eclipse,everything print ok in
> console. however,when i compile the project to jar ,and run it by start.bat
> ,log4j2 can.t print output in cmd window,i can't catch the reason,pls help
> me. thank you!