Wildfly 无法识别 jboss 部署结构文件 [英] Wildfly doesn't recognize jboss deployment structure file

查看:33
本文介绍了Wildfly 无法识别 jboss 部署结构文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 Wildfly 配置为使用每个部署日志记录和 jackson 作为 resteasy 上 json 的提供程序,但看起来 AS 无法识别文件jboss-deployment-structure.xml".

I'm trying to configure Wildfly to use per deployment logging and jackson as provider for json on resteasy but looks like the AS doesn't recognize the file "jboss-deployment-structure.xml".

我想记录 hibernate sql,我已经把 "<property name="hibernate.show_sql" value="true"/>" 放在persistence.xml 中.

I wanna log the hibernate sql, i already put "<property name="hibernate.show_sql" value="true"/>" in persistence.xml.

对于 Jackson,我使用以下方法:

And for Jackson, i use the following method:

    @GET
    @Path("/resumodia")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes("*/*")
    @GZIP
    public Response resumoHorariosDoDia() {
        try {
            final ResumoHorariosUsuarioDoDia resumoHorariosDoDia = geradorDeResumoHorarios.getResumoHorariosDoDia(new Date());

            return Response.status(OK).entity(resumoHorariosDoDia).build();
        } catch (Exception e) {
            return Response.status(INTERNAL_SERVER_ERROR).entity("Erro ao processar a requisição: " + e.getMessage()).build();
        }
    }

该方法有效,但它忽略了我在返回的对象上使用的 json 注释,例如 @JsonIgnore

The method works, but it ignores the json annotation i use on the object i return, like @JsonIgnore

文件是这样的:

<jboss-deployment-structure>
    <deployment>
        <exclude-subsystems>
            <subsystem name="logging" />
        </exclude-subsystems>
        <exclusions>
            <module name="org.jboss.resteasy.resteasy-jackson-provider"/>
            <module name="org.jboss.resteasy.resteasy-jettison-provider"/>
        </exclusions>
        <dependencies>
            <module name="org.apache.log4j"/>
            <module name="org.jboss.resteasy.resteasy-jackson2-provider" services="import"/>
        </dependencies>
    </deployment>
</jboss-deployment-structure>

我将文件放在 WEB-INF 中,但它一直使用 Wildfly 日志记录并忽略我的 log4j.xml.

I put the file inside WEB-INF but it keeps using the wildfly logging and ignoring my log4j.xml.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM
        "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xsi:schemaLocation="http://jakarta.apache.org/log4j/
http://jakarta.apache.org/log4j/ ">

    <appender name="stdout" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %5p [%-20c{1}] %m%n"/>
        </layout>
    </appender>

    <category name="br.com.caelum">
        <priority value="INFO"/>
        <appender-ref ref="stdout"/>
    </category>

    <category name="org.hibernate">
        <priority value="INFO"/>
        <appender-ref ref="stdout"/>
    </category>

    <category name="org.hibernate.SQL">
        <priority value="DEBUG"/>
        <appender-ref ref="stdout"/>
    </category>

    <category name="org.jboss">
        <priority value="INFO"/>
        <appender-ref ref="stdout"/>
    </category>

    <category name="org.razor.cponto">
        <priority value="INFO"/>
        <appender-ref ref="stdout"/>
    </category>

</log4j:configuration>

我使用的是 VRaptor 4

I'm using VRaptor 4

推荐答案

如果您只是想使用每个部署日志记录,只需将 log4j.xml 文件与您的部署一起打包,就无需与部署描述符混为一谈.然而,我注意到的是,您的 log4j 配置正在尝试附加到标准输出,而不是附加到特定于此特定部署的实际日志文件,因此它很可能实际上是在使用您的新配置,然后只是被合并到主要由于缺乏合适的appender,jboss日志记录

If you simply want to use per deployment logging, simply package your log4j.xml file with your deployment, there should be no need to mess about with deployment descriptors. What I do notice however is that your log4j config is trying to append to stdout rather than to an actual log file that is specific to this specific deployment, so it might well be actually using your new config, but then simply being merged into the main jboss logging due to lack of suitable appender

这篇关于Wildfly 无法识别 jboss 部署结构文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆