如何关闭Icefaces日志记录?

时间:2012-09-05 16:41:18

标签: java jsf log4j icefaces slf4j

我要求关闭Icefaces日志记录。我已经添加了如下的记录器参考,但我无法关闭Icefaces记录。

    <!-- I added this to filter off icefaces logging -->
    <logger name="org.icepush">
        <level value="OFF"/>
         <appender-ref ref="stdout"/>
    </logger>    
    <!-- I added this to filter off icefaces logging -->    
    <logger name="org.icefaces">
        <level value="OFF"/>
         <appender-ref ref="stdout"/>
    </logger>       
    <!-- I added this to filter off icefaces logging -->    
    <logger name="com.icesoft.faces.application.D2DViewHandler">
        <level value="OFF"/>
       <appender-ref ref="stdout"/>
    </logger> 

我使用Tomcat进行本地开发,使用Weblogic进行生产。

我的log4j.xml

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

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

    <!-- BEGIN APPENDER: RollingFileAppender (HBAppender) -->
    <appender class="org.apache.log4j.RollingFileAppender" name="HBAppender">
        <param value="${bla.root}/WEB-INF/frameworks.log" name="File"/>
        <param value="2" name="MaxBackupIndex"/>
        <param value="512KB" name="MaxFileSize"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param value="%d %p [%c] - %m%n" name="ConversionPattern"/>
        </layout>
    </appender>    
   <!-- BEGIN APPENDER: RollingFileAppender (JSFAppender) -->
    <appender class="org.apache.log4j.RollingFileAppender" name="JSFAppender">
        <param value="${bla.root}/WEB-INF/frameworks.log" name="File"/>
        <param value="2" name="MaxBackupIndex"/>
        <param value="512KB" name="MaxFileSize"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param value="%d %p [%c] - %m%n" name="ConversionPattern"/>
        </layout>
    </appender>    
    <!-- BEGIN APPENDER: RollingFileAppender (rotator) -->
    <appender class="org.apache.log4j.RollingFileAppender" name="rotator">
        <param value="true" name="Append"/>
        <param value="C:apache-tomcat-6.0.32LVSProjlogslvs.log" name="File"/>
        <param value="5" name="MaxBackupIndex"/>
        <param value="2048KB" name="MaxFileSize"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param value="[%d{MMM dd HH:mm:ss}] %-5p (%F:%L) - %m%n" name="ConversionPattern"/>
        </layout>
    </appender>    
   <!-- BEGIN APPENDER: RollingFileAppender (SFAppender) -->
    <appender class="org.apache.log4j.RollingFileAppender" name="SFAppender">
        <param value="${bla.root}/WEB-INF/frameworks.log" name="File"/>
        <param value="2" name="MaxBackupIndex"/>
        <param value="512KB" name="MaxFileSize"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param value="%d %p [%c] - %m%n" name="ConversionPattern"/>
        </layout>
    </appender>    
    <!-- BEGIN APPENDER: ConsoleAppender (stdout) -->
    <appender class="org.apache.log4j.ConsoleAppender" name="stdout">
        <layout class="org.apache.log4j.PatternLayout">
            <param value="[%d{MMM dd HH:mm:ss}] %-5p (%F:%L) - %m%n" name="ConversionPattern"/>
        </layout>
    </appender>    
    <!-- BEGIN APPENDER: DailyRollingFileAppender (APPLICATION) -->
    <appender class="org.apache.log4j.DailyRollingFileAppender" name="APPLICATION" >
        <param name="File" value="pem.log"/>
        <param name="DatePattern" value="'.'yyyy-MM-dd"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d %-5p %-17c{2} (%30F:%L) %3x - %m%n"/>
        </layout>
    </appender>    
    <!-- BEGIN APPENDER: DailyRollingFileAppender (AUDIT) -->
    <appender class="org.apache.log4j.DailyRollingFileAppender" name="AUDIT" >
      <param name="File" value="pem_audit.log"/> 
      <param name="DatePattern" value="'.'yyyy-MM-dd"/>
      <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%d %-5p [%t] %c - %m%n"/>
      </layout>      
    <filter class="org.apache.log4j.varia.DenyAllFilter"/>
   </appender>    
    <!-- logger references -->
    <logger name="org.apache">
        <appender-ref ref="JSFAppender"/>
    </logger>    
    <logger name="org.hibernate">
        <level value="info" />
        <appender-ref ref="HBAppender"/>
    </logger>    
    <logger name="org.springframework">
        <appender-ref ref="SFAppender"/>
    </logger>      
    <!-- I added this to filter off icefaces logging -->
    <logger name="org.icepush">
        <level value="OFF"/>
         <appender-ref ref="stdout"/>
    </logger>    
    <!-- I added this to filter off icefaces logging -->    
    <logger name="org.icefaces">
        <level value="OFF"/>
         <appender-ref ref="stdout"/>
    </logger>       
    <!-- I added this to filter off icefaces logging -->    
    <logger name="com.icesoft.faces.application.D2DViewHandler">
        <level value="OFF"/>
       <appender-ref ref="stdout"/>
    </logger>       
    <!-- root -->
    <root>
        <level value="info"/>
        <appender-ref ref="APPLICATION"/>
        <appender-ref ref="AUDIT"/>
        <appender-ref ref="stdout"/>
    </root>    
</log4j:configuration>

这是tomcat服务器启动时的控制台日志。我想过滤掉Icefaces相关的日志。

Sep 5, 2012 11:57:43 AM org.apache.catalina.core.AprLifecycleListener init    
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\IBM\SDP1\jdk\jre\bin;.;c:\oraclexe\app\oracle\product\11.2.0\server\bin;;C:\Development\axis2-1.5.4/bin;C:\Program Files\Java\jdk1.6.0_23/bin;C:\Development\apache-ant-1.7.0\bin;c:\cygwin\bin;c:\adams\filenet\IDM;c:\adams\filenet\Shared;C:\Shared;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\pb5;c:\sql\binn;c:\sql\dll;C:\MSSQL\BINN\;C:\Program Files\Executive Software\Diskeeper;C:\Program Files\Common Files\Roxio Shared\DLLShared\;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Windows Imaging\;C:\Program Files\Rational\common;C:\Program Files\Rational\ClearCase\bin;Y:\wpo4;S:\public;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Program Files\MySQL\MySQL Server 5.5\bin;c:\Program Files\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\VanDyke Software\Clients\
Sep 5, 2012 11:57:43 AM org.apache.tomcat.util.digester.SetPropertiesRule begin    
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:MyProj' did not find a matching property.    
Sep 5, 2012 11:57:43 AM org.apache.coyote.AbstractProtocol init    
INFO: Initializing ProtocolHandler ["http-bio-8081"]    
Sep 5, 2012 11:57:43 AM org.apache.coyote.AbstractProtocol init    
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]    
Sep 5, 2012 11:57:43 AM org.apache.catalina.startup.Catalina load    
INFO: Initialization processed in 1499 ms    
Sep 5, 2012 11:57:43 AM org.apache.catalina.core.StandardService startInternal    
INFO: Starting service Catalina    
Sep 5, 2012 11:57:43 AM org.apache.catalina.core.StandardEngine startInternal    
INFO: Starting Servlet Engine: Apache Tomcat/7.0.29    
Sep 5, 2012 11:57:44 AM org.apache.catalina.loader.WebappClassLoader validateJarFile    
INFO: validateJarFile(C:\Program Files\Apache Software Foundation\apache-tomcat-7.0.29\webapps\MyProj\WEB-INF\lib\servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
Sep 5, 2012 11:57:50 AM org.apache.catalina.core.ApplicationContext log    
INFO: Initializing Spring root WebApplicationContext    
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).    
log4j:WARN Please initialize the log4j system properly.    
SLF4J: Class path contains multiple SLF4J bindings.    
SLF4J: Found binding in [jar:file:/C:/Program%20Files/Apache%20Software%20Foundation/apache-tomcat-7.0.29/webapps/MyProj/WEB-INF/lib/slf4j-jcl-1.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]    
SLF4J: Found binding in [jar:file:/C:/Program%20Files/Apache%20Software%20Foundation/apache-tomcat-7.0.29/webapps/MyProj/WEB-INF/lib/slf4j-log4j12-1.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]    
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.    
[Sep 05 11:57:57] INFO  (JCLLoggerAdapter.java:284) - Trying to find Dozer configuration file: dozer.properties    
[Sep 05 11:57:57] WARN  (JCLLoggerAdapter.java:379) - Dozer configuration file not found: dozer.properties.  Using defaults for all Dozer global properties.    
[Sep 05 11:57:57] INFO  (JCLLoggerAdapter.java:307) - Initializing Dozer. Version: 5.3.2, Thread Name: localhost-startStop-1    
[Sep 05 11:57:57] INFO  (JCLLoggerAdapter.java:263) - Dozer JMX MBean [org.dozer.jmx:type=DozerStatisticsController] auto registered with the Platform MBean Server    
[Sep 05 11:57:57] INFO  (JCLLoggerAdapter.java:263) - Dozer JMX MBean [org.dozer.jmx:type=DozerAdminController] auto registered with the Platform MBean Server    
[Sep 05 11:57:57] INFO  (JCLLoggerAdapter.java:263) - Initializing a new instance of dozer bean mapper.    
Sep 5, 2012 11:57:57 AM com.sun.faces.config.ConfigureListener contextInitialized    
INFO: Initializing Mojarra 2.1.1 (FCS 20110408) for context '/MyProj'    
Sep 5, 2012 11:57:58 AM com.sun.faces.spi.InjectionProviderFactory createInstance    
INFO: JSF1048: PostConstruct/PreDestroy annotations present.  ManagedBeans methods marked with these annotations will have said annotations processed.    
Sep 5, 2012 11:57:58 AM org.icepush.servlet.MainServlet <init>    
INFO: 
ICEsoft Technologies Inc.    
ICEpush 2.0.0    
Build number: 1    
Revision: 23556    

Sep 5, 2012 11:58:16 AM org.icefaces.util.EnvConfig init        
INFO: ICEfaces Configuration:         
org.icefaces.render.auto: true [default]        
org.icefaces.autoid: true [default]    
org.icefaces.aria.enabled: true [default]    
org.icefaces.blockUIOnSubmit: false [default]    
org.icefaces.compressDOM: false [default]    
org.icefaces.compressResources: true [default]    
org.icefaces.connectionLostRedirectURI: null [default]    
org.icefaces.deltaSubmit: false [default]    
org.icefaces.lazyPush: true [default]    
org.icefaces.sessionExpiredRedirectURI: null [default]    
org.icefaces.standardFormSerialization: false [default]    
org.icefaces.strictSessionTimeout: false [default]    
org.icefaces.windowScopeExpiration = 1000 [default]    
org.icefaces.mandatoryResourceConfiguration: null [default]    
org.icefaces.uniqueResourceURLs: true [default]    

Sep 5, 2012 11:58:16 AM org.icefaces.impl.renderkit.DOMRenderKit <clinit>    
INFO:     
ICEsoft Technologies Inc.    
ICEfaces 2.0.0    
Build number: 4    
Revision: 23692

2 个答案:

答案 0 :(得分:2)

commons-logging.properties添加到包含内容的src文件夹

org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger

每当它使用公共日志记录时,它将被用于log4j。应相应地配置log4j日志记录。确保将log4j.jar添加到类路径中。

但是,icefaces最终会使用java.util.logging记录器。您必须使用其日志记录配置。为此,您需要在服务器启动配置中添加-Djava.util.logging.config.file=\path\to\logging.properties选项。

简单文件logging.properties位于 JDK \ JRE \ lib 文件夹中。您可以使用它并添加

org.icepush.level = OFF
org.icefaces.level = OFF
javax.faces.level = OFF
com.sun.faces.level = OFF

到文件末尾。

如果您使用Eclipse,请使用首选项 - &gt;服务器 - &gt; JDK - &gt;可选的Java VM参数:将此选项添加到服务器JDK。或者,您可以创建服务器启动配置首选项 - &gt;服务器 - &gt;启动 - &gt;创建启动配置并在那里定义此选项。您可以为同一服务器创建多个启动配置。最近,您可以通过指定服务器启动配置将此配置映射到应用程序运行配置。

答案 1 :(得分:1)

我发现了几种抑制Icefaces日志的方法。我将以下所有内容列为正面和缺点。我选择了2。

1)在jdk中编辑logging.properties

PROS:快速轻松地进行更改,不需要进行任何其他更改,也不会影响现有的日志记录配置,所有需要抑制的类都可以放在一个位置。 缺点:全局变化,使用此jdk的所有应用程序都受到此更改的影响。

2)在服务器启动时将单独的log4j.xml加载到classpath并从那里禁止Icefaces日志。

PROS:WLS可以保留在JDK日志记录中。 缺点:全球变化,涉及一些配置。

3)在WLS上启用log4j并在服务器启动时将log4j.xml加载到classpath。

PROS:所有日志记录(WLS和个人应用程序)都将在log4j上。我们可以将服务器级别log4j.xml用于我们想要的所有应用程序,例如禁用Icefaces日志记录,我们可以在应用程序内部使用另一个log4j文件来告诉此应用程序如何使用log4j进行日志记录。 缺点:涉及配置WLS以使用log4j,需要维护单独的全局log4j文件。