log4j.xml(信息打印)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j=‘http://jakarta.apache.org/log4j/‘ >

<appender name="myConsole" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="[%d{dd HH:mm:ss,SSS\} %-5p] [%t] %c{2\} - %m%n" />
</layout>
<!--过滤器设置输出的级别-->
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="levelMin" value="debug" />
<param name="levelMax" value="warn" />
<param name="AcceptOnMatch" value="true" />
</filter>
</appender>

<appender name="myFile" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="D:/output.log" /><!-- 设置日志输出文件名 -->
<!-- 设置是否在重新启动服务时,在原有日志的基础添加新日志 -->
<param name="Append" value="true" />
<param name="MaxBackupIndex" value="10" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%p (%c:%L)- %m%n" />
</layout>
</appender>

<appender name="activexAppender" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="E:/activex.log" />
<param name="DatePattern" value="‘.‘yyyy-MM-dd‘.log‘" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="[%d{MMdd HH:mm:ss SSS\} %-5p] [%t] %c{3\} - %m%n" />
</layout>
</appender>

<!-- 指定logger的设置,additivity指示是否遵循缺省的继承机制-->
<logger name="com.runway.bssp.activeXdemo" additivity="false">
<priority value ="info"/>
<appender-ref ref="activexAppender" />
</logger>

<!-- 根logger的设置-->
<root>
<priority value ="debug"/>
<appender-ref ref="myConsole"/>
<appender-ref ref="myFile"/>
</root>
</log4j:configuration>

时间: 2024-11-09 07:16:27

log4j.xml(信息打印)的相关文章

log4j.properties(信息打印)

### set log levels ###log4j.rootLogger = INFO , console , debug , error ### console ###log4j.appender.console = org.apache.log4j.ConsoleAppenderlog4j.appender.console.Target = System.outlog4j.appender.console.layout = org.apache.log4j.PatternLayoutlo

log4j.xml打印日志信息(2)

log4j.xml文件 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/' > <appender name="myConsole&qu

log4j.xml配置文件

<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <!-- 根节点的配置顺序: renderer appender pl

log4j(七)——log4j.xml简单配置样例说明

一:测试环境与log4j(一)--为什么要使用log4j?一样,这里不再重述 二:老规矩,先来个栗子,然后再聊聊感受 (1)这里栗子有一点特别呀!给出了包名唉!想必有用,是的,配置文件中要特别说明一下的 package test.log4j.test8; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; import org.apache.log4j.xml.DOMConfigurator; /** * Cre

log4j.xml配置示例

这是log4j1.x版本讲解,log4j-1.2.16.jar    1. 一般的log4j.xml的两种配置方式: 1.Logger 完成日志信息的处理定义输出的层次和决定信息是否输出DEBUG<INFO<WARN<ERROR 2.Appender 设置日志信息的去向常用的:org.apache.log4j.ConsoleAppender(控制台)org.apache.log4j.FileAppender(文件)org.apache.log4j.DailyRollingFileAppe

log4j.xml的实用例子

大多数讲log4j配置的教程用的都是log4j.properties文件,我觉得xml或许更好一点,在这里我提供一个我已经用于生产环境的log4j.xml的例子,先上代码,然后再解释: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "log4j.

log4j日志文件 log4j.xml log4j.properties配置

1,导入log4j  jar包; 2,配置log4j.xml或log4j.properties文件; ----------------------------------------------------------------------------------------------------------- <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE log4j:configuratio

解决log4j.xml问题http//jakarta.apache.org/log4j/ uri is not registered

在Eclipse中,配置log4j.xml出现"http //jakarta.apache.org/log4j/ uri is not registered"的错误信息. 原始的log4j.xml配置文件: <?xml version="1.0" encoding="GB2312" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4

log4j 突然不打印记录,提示:No appenders could be found for logge,处理方法

log4j 一直都在使用正常,log4j.xml配置.代码都没有修改,突然不打印记录,出现下面提示: log4j:WARN No appenders could be found for logger (com.fc.htgl.testcases.TestOrderPrice).log4j:WARN Please initialize the log4j system properly.log4j:WARN See http://logging.apache.org/log4j/1.2/faq.