重复日志 - Wildfly 9

时间:2018-01-07 04:05:51

标签: log4j wildfly-9

我有两个Web应用程序,都在我自己的Web服务器上运行正常,但是当我在另一个服务器上发布时,这个服务器打印两次相同的日志,但在我的服务器上,应用程序正在打印一切正常。 我为我的应用程序创建了一个特定的记录器,类别是bo.com.tucomilona,因此重复的日志仅适用于此类别,其他日志在server.log中打印正常。

standalone.xml的配置是

<subsystem xmlns="urn:jboss:domain:logging:3.0">
        <console-handler name="CONSOLE">
            <level name="DEBUG"/>
            <formatter>
               <named-formatter name="COLOR-PATTERN"/>
            </formatter>
        </console-handler>
        <periodic-rotating-file-handler name="FILE" autoflush="true">
            <level name="DEBUG"/>
            <formatter>
                <named-formatter name="COLOR-PATTERN"/>
            </formatter>
            <file relative-to="jboss.server.log.dir" path="server.log"/>
            <suffix value=".yyyy-MM-dd"/>
            <append value="true"/>
        </periodic-rotating-file-handler>
        <logger category="com.arjuna">
            <level name="WARN"/>
        </logger>
        <logger category="org.apache.tomcat.util.modeler">
            <level name="WARN"/>
        </logger>
        <logger category="org.jboss.as.config">
            <level name="INFO"/>
        </logger>
        <logger category="sun.rmi">
            <level name="WARN"/>
        </logger>
        <logger category="jacorb">
            <level name="WARN"/>
        </logger>
        <logger category="jacorb.config">
            <level name="ERROR"/>
        </logger>
        <logger category="bo.com.tucomilona">
            <level name="DEBUG"/>
            <handlers>
                <handler name="FILE"/>
            </handlers>
        </logger>
        <root-logger>
            <level name="INFO"/>
            <handlers>
                <handler name="CONSOLE" />
                <handler name="FILE"/>
            </handlers>
        </root-logger>
        <formatter name="PATTERN">
            <pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
        </formatter>
        <formatter name="COLOR-PATTERN">
            <pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
        </formatter>
    </subsystem>

这些是重复的日志:

23:36:23,584 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0010: Deployed "tucomilona-frontend.war" (runtime-name : "tucomilona-frontend.war")
23:36:23,584 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0010: Deployed "tucomilona-rest.war" (runtime-name : "tucomilona-rest.war")
23:36:23,584 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0010: Deployed "mysql-connector-java-5.1.6-bin.jar" (runtime-name : "mysql-connector-java-5.1.6-bin.jar")
23:36:23,844 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://[0:0:0:0:0:0:0:0]:9990/management
23:36:23,844 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://[0:0:0:0:0:0:0:0]:9990
23:36:23,845 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 9.0.2.Final (WildFly Core 1.0.2.Final) started in 44618ms - Started 783 of 982 services (254 services are lazy, passive or on-demand)
23:36:42,821 INFO  [bo.com.tucomilona.rest.endpoint.RestaurantRestEndPoint] (default task-1) Cargado de la pantalla principal.
23:36:42,821 INFO  [bo.com.tucomilona.rest.endpoint.RestaurantRestEndPoint] (default task-1) Cargado de la pantalla principal.
23:36:42,823 DEBUG [bo.com.tucomilona.service.cache.CacheService] (default task-1) Postconstruct - CacheService
23:36:42,823 DEBUG [bo.com.tucomilona.service.cache.CacheService] (default task-1) Postconstruct - CacheService
23:36:43,001 DEBUG [bo.com.tucomilona.service.cache.CacheService] (default task-1) Inicianlizando cacheo de datos de los restaurantes, cantidad de restaurantes: 101
23:36:43,001 DEBUG [bo.com.tucomilona.service.cache.CacheService] (default task-1) Inicianlizando cacheo de datos de los restaurantes, cantidad de restaurantes: 101
23:36:45,011 DEBUG [bo.com.tucomilona.service.cache.CacheService] (default task-1) Inicializando el cacheo de categorias de restaurantes
23:36:45,011 DEBUG [bo.com.tucomilona.service.cache.CacheService] (default task-1) Inicializando el cacheo de categorias de restaurantes
23:36:45,014 DEBUG [bo.com.tucomilona.service.cache.CacheService] (default task-1) Inicializando el cacheo de categorias de productos por restaurant, cantidad de restaurantes habilitados: 101
23:36:45,014 DEBUG [bo.com.tucomilona.service.cache.CacheService] (default task-1) Inicializando el cacheo de categorias de productos por restaurant, cantidad de restaurantes habilitados: 101
23:36:46,607 DEBUG [bo.com.tucomilona.service.cache.CacheService] (default task-1) Inicializando cacheo de productos habilitados, cantidad: 3286
23:36:46,607 DEBUG [bo.com.tucomilona.service.cache.CacheService] (default task-1) Inicializando cacheo de productos habilitados, cantidad: 3286

如您所见,命名空间bo.com.tucomilona中的日志是重复的,但其他日志不是。

1 个答案:

答案 0 :(得分:0)

如果您只希望这些日志转到FILE处理程序,则需要将use-parent-handlers设置为false。在CLI中,命令如下所示:

/subsystem=logging/logger=bo.com.tucomilona:write-attribute(name=use-parent-handlers, value=false)

如果您希望这些日志消息同时发送给FILECONSOLE处理程序,那么您只需从记录器中删除FILE处理程序。

/subsystem=logging/logger=bo.com.tucomilona:remove-handler(name=FILE)