`
Aillen0209
  • 浏览: 9355 次
  • 性别: Icon_minigender_2
  • 来自: 西安
社区版块
存档分类
最新评论

Log4j

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

<!-- ===================================================================== -->
<!--                                                                       -->
<!--  Log4j Configuration                                                  -->
<!--                                                                       -->
<!-- ===================================================================== -->

<!-- $Id: jboss-log4j.xml 87678 2009-04-22 16:47:08Z bstansberry@jboss.com $ -->

<!--
   | For more configuration information and examples see the Jakarta Log4j
   | owebsite: http://jakarta.apache.org/log4j
-->

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">

   <!-- ================================= -->
   <!-- Preserve messages in a local file -->
   <!-- ================================= -->

   <!-- A time/date based rolling appender -->
   <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
      <param name="File" value="${jboss.server.log.dir}/server.log"/>
      <param name="Append" value="true"/>
      <!-- In AS 5.0.x the server log threshold was set by a system
           property. In 5.1 and later we are instead using the system
           property to set the priority on the root logger (see <root/> below)
      <param name="Threshold" value="${jboss.server.log.threshold}"/>
      -->
     
      <!-- Rollover at midnight each day -->
      <param name="DatePattern" value="'.'yyyy-MM-dd"/>

      <!-- Rollover at the top of each hour
      <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
      -->

      <layout class="org.apache.log4j.PatternLayout">
         <!-- The default pattern: Date Priority [Category] (Thread) Message\n -->
         <param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n"/>

         <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
         <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
          -->
      </layout>
   </appender>

   <!-- A size based file rolling appender
   <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
     <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
     <param name="File" value="${jboss.server.log.dir}/server.log"/>
     <param name="Append" value="false"/>
     <param name="MaxFileSize" value="500KB"/>
     <param name="MaxBackupIndex" value="1"/>

     <layout class="org.apache.log4j.PatternLayout">
       <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
     </layout>    
   </appender>
   -->

   <!-- ============================== -->
   <!-- Append messages to the console -->
   <!-- ============================== -->

   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
      <param name="Target" value="System.out"/>
      <param name="Threshold" value="INFO"/>

      <layout class="org.apache.log4j.PatternLayout">
         <!-- The default pattern: Date Priority [Category] Message\n -->
         <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
      </layout>
   </appender>

   <!-- ====================== -->
   <!-- More Appender examples -->
   <!-- ====================== -->

   <!-- Buffer events and log them asynchronously
   <appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
     <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
     <appender-ref ref="FILE"/>
     <appender-ref ref="CONSOLE"/>
     <appender-ref ref="SMTP"/>
   </appender>
   -->

   <!-- EMail events to an administrator
 
   -->
   <appender name="SMTP" class="org.apache.log4j.net.SMTPAppender">
     <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
     <param name="Threshold" value="ERROR"/>
     <param name="To" value="Aillen@qq.com,Dan.xu@qq.com"/>
     <param name="From" value="JBossAdmin.vg@qq.com"/>
     <param name="Subject" value="JBoss Sever Errors on NHRS1042 (HOU2)"/>
     <param name="SMTPHost" value="e2ksmtp.e2k.com"/>-----mail server name
     <param name="BufferSize" value="10"/>
     <layout class="org.apache.log4j.PatternLayout">
       <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
     </layout>
   </appender>
  

   <!-- Syslog events
   <appender name="SYSLOG" class="org.apache.log4j.net.SyslogAppender">
     <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
     <param name="Facility" value="LOCAL7"/>
     <param name="FacilityPrinting" value="true"/>
     <param name="SyslogHost" value="localhost"/>
     <layout class="org.apache.log4j.PatternLayout">
       <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
     </layout>
   </appender>
   -->

   <!-- Log events to JMS (requires a topic to be created)
   <appender name="JMS" class="org.apache.log4j.net.JMSAppender">
     <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
     <param name="Threshold" value="ERROR"/>
     <param name="TopicConnectionFactoryBindingName" value="java:/ConnectionFactory"/>
     <param name="TopicBindingName" value="topic/MyErrorsTopic"/>
   </appender>
   -->

   <!-- Log events through SNMP
   <appender name="TRAP_LOG" class="org.apache.log4j.ext.SNMPTrapAppender">
     <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
     <param name="ImplementationClassName" value="org.apache.log4j.ext.JoeSNMPTrapSender"/>
     <param name="ManagementHost" value="127.0.0.1"/>
     <param name="ManagementHostTrapListenPort" value="162"/>
     <param name="EnterpriseOID" value="1.3.6.1.4.1.24.0"/>
     <param name="LocalIPAddress" value="127.0.0.1"/>
     <param name="LocalTrapSendPort" value="161"/>
     <param name="GenericTrapType" value="6"/>
     <param name="SpecificTrapType" value="12345678"/>
     <param name="CommunityString" value="public"/>
     <param name="ForwardStackTraceWithTrap" value="true"/>
     <param name="Threshold" value="DEBUG"/>
     <param name="ApplicationTrapOID" value="1.3.6.1.4.1.24.12.10.22.64"/>
     <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d,%p,[%t],[%c],%m%n"/>
     </layout>
   </appender>
   -->

   <!--  Emit events as JMX notifications
   <appender name="JMX" class="org.jboss.monitor.services.JMXNotificationAppender">
      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
     
      <param name="Threshold" value="WARN"/>
      <param name="ObjectName" value="jboss.system:service=Logging,type=JMXNotificationAppender"/>
     
      <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="%d %-5p [%c] %m"/>
      </layout>
   </appender>
   -->

   <!-- Security AUDIT Appender
   <appender name="AUDIT" class="org.jboss.logging.appender.DailyRollingFileAppender">
      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
      <param name="File" value="${jboss.server.log.dir}/audit.log"/>
      <param name="Append" value="true"/>
      <param name="DatePattern" value="'.'yyyy-MM-dd"/>
      <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="%d %-5p [%c] (%t:%x) %m%n"/>
      </layout>
   </appender>
   -->
  
   <!-- ================ -->
   <!-- Limit categories -->
   <!-- ================ -->

   <!-- Limit the org.apache category to INFO as its DEBUG is verbose -->
   <category name="org.apache">
      <priority value="INFO"/>
   </category>
  
   <!-- Limit the jacorb category to WARN as its INFO is verbose -->
   <category name="jacorb">
      <priority value="WARN"/>
   </category>
  
   <!-- Limit the com.arjuna category to WARN as its INFO is verbose -->
   <category name="com.arjuna">
         <priority value="WARN"/>
   </category>
     
   <!-- Limit the org.hibernate category to WARN -->
   <category name="org.hibernate">
   <priority value="WARN"/>
   </category>
  
   <!-- Set the logging level of the JSF implementation that uses
      | java.util.logging. The jdk logging levels can be controlled
      | through the org.jboss.logging.log4j.JDKLevel class that
      | in addition to the standard log4j levels it adds support for
      | SEVERE, WARNING, CONFIG, FINE, FINER, FINEST
   -->
   <category name="javax.enterprise.resource.webcontainer.jsf">
     <priority value="WARN" class="org.jboss.logging.log4j.JDKLevel"/>
   </category>
  
   <!-- Limit the org.jgroups category to WARN as its INFO is verbose -->
   <category name="org.jgroups">
      <priority value="WARN"/>
   </category>
  
   <!-- Limit the org.quartz category to INFO as its DEBUG is verbose -->
   <category name="org.quartz">
      <priority value="INFO"/>
   </category>
  
   <!-- Limit the com.sun category to INFO as its FINE is verbose -->
   <category name="com.sun">
      <priority value="WARN"/>
   </category>
  
   <!-- Limit the sun category to INFO as its FINE is verbose -->
   <category name="sun">
      <priority value="WARN"/>
   </category>
  
   <!-- Limit the javax.xml.bind category to INFO as its FINE is verbose -->
   <category name="javax.xml.bind">
      <priority value="INFO"/>
   </category>
  
   <!-- Limit JBoss categories
   <category name="org.jboss">
      <priority value="INFO"/>
   </category>
   -->

   <!-- Limit the JSR77 categories -->
   <category name="org.jboss.management">
      <priority value="INFO"/>
   </category>

   <!-- Limit the verbose facelets compiler -->
   <category name="facelets.compiler">
      <priority value="WARN"/>
   </category>
  
   <!-- Limit the verbose ajax4jsf initialization -->
   <category name="org.ajax4jsf">
      <priority value="WARN"/>
   </category>
  
   <!-- Limit the verbose embedded jopr categories -->
   <category name="org.rhq">
      <priority value="WARN"/>
   </category>
  
   <!-- Limit the verbose seam categories -->
   <category name="org.jboss.seam">
      <priority value="WARN"/>
   </category>
  
   <!-- Show the evolution of the DataSource pool in the logs [inUse/Available/Max]
   <category name="org.jboss.resource.connectionmanager.JBossManagedConnectionPool">
     <priority value="TRACE"/>
   </category>
   -->

   <!-- Category specifically for Security Audit Provider
   <category name="org.jboss.security.audit.providers.LogAuditProvider" additivity="false">
     <priority value="TRACE"/>
     <appender-ref ref="AUDIT"/>
   </category>
   -->
  
   <!-- Limit the org.jboss.serial (jboss-serialization) to INFO as its DEBUG is verbose -->
   <category name="org.jboss.serial">
      <priority value="INFO"/>
   </category>
 
   <!-- Decrease the priority threshold for the org.jboss.varia category
   <category name="org.jboss.varia">
     <priority value="DEBUG"/>
   </category>
   -->
  
   <!-- Enable JBossWS message tracing
   <category name="org.jboss.ws.core.MessageTrace">
     <priority value="TRACE"/>
   </category>
   -->
  
   <!--
      | An example of enabling the custom TRACE level priority that is used
      | by the JBoss internals to diagnose low level details. This example
      | turns on TRACE level msgs for the org.jboss.ejb.plugins package and its
      | subpackages. This will produce A LOT of logging output.
      |
      | Note: since jboss AS 4.2.x, the trace level is supported natively by
      | log4j, so although the custom org.jboss.logging.XLevel priority will
      | still work, there is no need to use it. The two examples that follow
      | will both enable trace logging.
   <category name="org.jboss.system">
     <priority value="TRACE" class="org.jboss.logging.XLevel"/>
   </category>
   <category name="org.jboss.ejb.plugins">
     <priority value="TRACE"/>
   </category>
   -->
 
   <!--
       | Logs these events to SNMP:
           - server starts/stops
           - cluster evolution (node death/startup)
           - When an EJB archive is deployed (and associated verified messages)
           - When an EAR archive is deployed
     
   <category name="org.jboss.system.server.Server">
     <priority value="INFO" />
     <appender-ref ref="TRAP_LOG"/>
   </category>
 
   <category name="org.jboss.ha.framework.interfaces.HAPartition.lifecycle">
     <priority value="INFO" />
     <appender-ref ref="TRAP_LOG"/>
   </category>

   <category name="org.jboss.deployment.MainDeployer">
     <priority value="ERROR" />
     <appender-ref ref="TRAP_LOG"/>
   </category>
  
   <category name="org.jboss.ejb.EJBDeployer">
     <priority value="INFO" />
     <appender-ref ref="TRAP_LOG"/>
   </category>
  
   <category name="org.jboss.deployment.EARDeployer">
     <priority value="INFO" />
     <appender-ref ref="TRAP_LOG"/>
   </category>
   -->

   <!-- Clustering logging -->
   <!-- Uncomment the following to redirect the org.jgroups and
      org.jboss.ha categories to a cluster.log file.

   <appender name="CLUSTER" class="org.jboss.logging.appender.RollingFileAppender">
     <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
     <param name="File" value="${jboss.server.log.dir}/cluster.log"/>
     <param name="Append" value="false"/>
     <param name="MaxFileSize" value="500KB"/>
     <param name="MaxBackupIndex" value="1"/>

     <layout class="org.apache.log4j.PatternLayout">
       <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
     </layout>
   </appender>
   <category name="org.jgroups">
     <priority value="DEBUG" />
     <appender-ref ref="CLUSTER"/>
   </category>
   <category name="org.jboss.ha">
     <priority value="DEBUG" />
     <appender-ref ref="CLUSTER"/>
   </category>
   -->
  
   <!-- ======================= -->
   <!-- Setup the Root category -->
   <!-- ======================= -->

   <root>
      <!--
         Set the root logger priority via a system property. Note this is parsed by log4j,
         so the full JBoss system property format is not supported; e.g.
         setting a default via ${jboss.server.log.threshold:WARN} will not work.        
       -->
      <priority value="${jboss.server.log.threshold}"/>
     
      <!--
      Disable CONSOLE logging in Production environments.
      <appender-ref ref="CONSOLE"/>
      -->
     
      <appender-ref ref="SMTP"/>
      <appender-ref ref="FILE"/>
   </root>

</log4j:configuration>

分享到:
评论

相关推荐

    老生常谈Log4j和Log4j2的区别(推荐)

    Log4j只需要引入一个JAR包,即log4j.jar,而Log4j2则需要引入两个核心JAR包,即log4j-core.jar和log4j-api.jar。大家可以发现,Log4j和Log4j2的包路径是不同的,Apache为了区分,包路径都更新了。 文件渲染 Log4j...

    若依框架使用的log4j2.16.0,修复log4j漏洞log4j2下载最新log4j2.16.0下载

    Log4j是一个广泛使用的Java日志记录框架,它允许开发者在应用程序中轻松地记录各种级别的日志信息,如DEBUG、INFO、WARN、ERROR等。在2021年底,一个重大的安全漏洞(CVE-2021-44228)被发现在Log4j2的早期版本中,...

    Log4j2学习用到的jar包及apache-log4j-2.19.0-bin.zip

    分别有disruptor-3.3.4.jar(Log4j2异步日志的底层实现)、log4j-api-2.19.0.jar(log4j门面)、log4j-core-2.19.0.jar(log4j实现)、log4j-slf4j-impl-2.19.0.jar(SLF4J与Log4j绑定)、slf4j-api-1.7.30.jar(SLF...

    logging-log4j2-log4j-2.15.0-rc2.zip maven 资源库

    针对Log4j 2 远程代码执行漏洞,需要用到的升级资源包,适用于maven资源库,包括log4j,log4j-core,log4j-api,log4j-1.2-api,log4j-jpa等全套2.15.0 maven资源库jar包。如果是maven本地仓库使用,需要将zip包解压...

    Log4j2简介及与Log4j效率对比

    ### Log4j2简介 Log4j2是Apache软件基金会推出的日志框架,它是Log4j 1.x的重构版本,旨在提供更为高效且灵活的日志解决方案。与Log4j 1.x相比,Log4j2在设计上进行了重大改进,并解决了Logback等其他日志框架中...

    log4j.jar各个版本

    apache-log4j-1.2.15.jar, apache-log4j-extras-1.0.jar, apache-log4j-extras-1.1.jar, apache-log4j.jar, log4j-1.2-api-2.0.2-javadoc.jar, log4j-1.2-api-2.0.2-sources.jar, log4j-1.2-api-2.0.2.jar, log4j-...

    log4j+slf4j实现 log4j测试代码,log4j+slf4j实现 log4j测试代码

    总结,SLF4J和Log4j的组合使用让日志管理更加灵活,开发者可以通过SLF4J的简洁API进行日志记录,同时利用Log4j的强大功能,如自定义输出格式和多种输出目的地。通过适当的配置和测试,我们可以确保日志系统按照预期...

    log4j-core-2.15.0.jar log4j-2.15.0-rc2

    Apache log4j2零日漏洞,根据 log4j-2.15.0-rc2 版本编译生成log4j-api-2.15.0.jar 1.解压你的jar jar xvf XXX.jar 2. 删除旧版本jar cd ./BOOT-INF/lib rm -rf log4j-api-*.jar 3. 上传新版本log4j-api-2.15.0....

    Log4j2、Fastjson、Log4j的BurpSuite插件亲测有效

    Log4j、Log4j2和Fastjson的安全性问题在过去曾引起广泛关注,例如Log4j2的CVE-2021-44228(也被称为Log4Shell漏洞),这是一个远程代码执行漏洞,影响了许多使用Log4j2的系统。这个插件可能就是为了检测和利用这些...

    SpringBoot框架配置log4j和log4j2的配置代码

    Log4j和Log4j2是两种广泛使用的Java日志框架,它们提供了灵活的日志配置和高性能的日志处理能力。本文将详细介绍如何在SpringBoot项目中配置Log4j和Log4j2。 ### SpringBoot与Log4j Log4j是Apache的一个开源项目,...

    log4j-api-2.12.4.ja和log4j-core-2.12.4.jar

    此次提及的`log4j-api-2.12.4.jar`和`log4j-core-2.12.4.jar`是Log4j 2框架的两个关键组件,版本号为2.12.4,这个版本主要修复了之前版本中可能存在的安全漏洞。 **log4j-api-2.12.4.jar** 是Log4j 2框架的API模块...

    logging-log4j2-log4j-2.15.0-rc2.zip

    《深入理解Log4j 2.15.0-rc2:日志处理的关键技术解析》 Log4j,作为Java领域广泛使用的日志记录框架,一直以来都是开发者们的重要工具。这次我们关注的是其最新版本——logging-log4j2-log4j-2.15.0-rc2。这个版本...

    log4j.properties(完整版) log4j.properties(精简版)

    **日志框架Log4j详解** 在Java开发中,日志记录是一项不可或缺的功能,它能够帮助开发者追踪程序运行状态,定位错误,优化性能,并为后期维护提供重要信息。Log4j是Apache组织开发的一个强大的、灵活的日志记录框架...

    log4j-2.18.0

    《log4j-2.18.0:修复重大安全漏洞的紧急更新》 在IT领域,安全性始终是首要关注的问题。近期,一个名为“log4j2”的严重安全漏洞引发了广泛关注,它影响了所有log4j2版本,从2.0开始直到2.18.0版本之前。这个漏洞...

    log4j-api-2.15.0.jar log4j-2.15.0-rc2

    Apache log4j2零日漏洞,根据 log4j-2.15.0-rc2 版本编译生成log4j-api-2.15.0.jar 1.解压你的jar jar xvf XXX.jar 2. 删除旧版本jar cd ./BOOT-INF/lib rm -rf log4j-api-*.jar 3. 上传新版本log4j-api-...

    log4j-api-2.17.1.jar和log4j-core-2.17.1.jar

    《深入理解log4j-api-2.17.1.jar与log4j-core-2.17.1.jar》 在Java开发中,日志管理是不可或缺的一部分,它帮助我们跟踪程序运行状态、定位错误和调试问题。Log4j作为一款广泛使用的日志框架,历经多次迭代,现在...

    logging-log4j2-log4j-2.16.0-rc1.zip

    总的来说,"logging-log4j2-log4j-2.16.0-rc1.zip"的发布是Log4j团队对"Log4Shell"漏洞的有力回应,通过禁用可能导致安全问题的功能,提高了整体的安全标准。这一事件提醒我们,安全无小事,及时的更新和维护是保障...

    log4j示例项目

    这个“log4j示例项目”旨在帮助开发者理解和使用Log4j,通过该项目,我们可以深入学习Log4j的配置、使用方法以及其在实际开发中的应用。 **1. Log4j的组成部分** Log4j主要包括三个核心组件:Logger(日志器)、...

    log4j-API-最新稳定版本log4j-1.2.17

    标题提及的是"log4j-API-最新稳定版本log4j-1.2.17",这表明我们关注的是日志框架Log4j的一个特定版本,即1.2.17。Log4j是Apache软件基金会开发的一个用于Java应用程序的日志记录工具,它提供了灵活的日志记录功能,...

    apache-log4j-2.17.0 核心jar包

    Log4j 是一个日志记录框架,Log4j 2 是对 Log4j 的升级,提供了重大改进,超越其前身 Log4j 1.x,并提供许多其它现代功能 ,例如对标记的支持、使用查找的属性替换、lambda 表达式与日志记录时无垃圾等。 Apache ...

Global site tag (gtag.js) - Google Analytics