Wildfly Maven 插件 - 命令似乎没有效果

Wildfly Maven Plugin - commands seem to have no effect

我正在使用 Wildfly Maven 插件并且它正在运行,因为它打开并运行 Web 应用程序,但是我在自定义配置方面遇到了问题,即:

这是我的设置:

<plugin>
    <groupId>org.wildfly.plugins</groupId>
    <artifactId>wildfly-maven-plugin</artifactId>
    <version>2.0.2.Final</version>
    <executions>
        <execution>
            <phase>install</phase>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <java-opts>
            <java-opt>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044</java-opt>
        </java-opts>
        <commands>
            <!-- **These are the commands that aren't going through** -->
            <command>/subsystem=logging/root-logger=ROOT:write-attribute(name="level", value="DEBUG") </command>
            <command>/subsystem=logging/console-handler=CONSOLE:write-attribute(name="level", value="DEBUG")</command>
            <command>/subsystem=logging/file-handler=debug:add(level=DEBUG,autoflush=true,file={"relative-to"=>"jboss.server.log.dir", "path"=>"debug.log"})</command>
            <command>/subsystem=logging/logger=org.jboss.as:add(level=DEBUG,handlers=[debug])</command>
            <command>/subsystem-----Enable Remote access here?</command>
        </commands>
        <add-user>
            <users>
                <user>
                    <username>admin</username>
                    <password>admin.1234</password>
                </user>
                <user>
                    <username>admin-user</username>
                    <password>user.1234</password>
                    <groups>
                        <group>admin</group>
                        <group>user</group>
                    </groups>
                    <application-user>true</application-user>
                </user>
                <user>
                    <username>default-user</username>
                    <password>user.1234</password>
                    <groups>
                        <group>user</group>
                    </groups>
                    <application-user>true</application-user>
                </user>
            </users>
        </add-user>
    </configuration>
</plugin>

我知道从终端开始时,人们会使用这个:./standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0 但是我 运行 直接从 Maven 进行演示,需要从另一台机器访问我的 webapp。

注意 - 在 Wildfly 管理页面中,我可以手动将 Root Logger 和 Console Logger 设置为调试模式,然后正确的调试日志就会流出。

例如,我可以手动转到此处:http://127.0.0.1:9990/console/index.html#logging-configuration,然后手动将日志记录从默认的 INFO 级别更改为 DEBUG:

所以我的问题是,除了允许远程访问之外,如何将日志记录级别作为命令更改到 maven wildfly 插件中。

您需要将插件版本升级到 2.1.0.Beta1 才能使其正常工作。 2.0.x 版本无法从 运行 或部署目标执行 CLI 命令。

如果您需要坚持使用您正在使用的版本,则需要定义 execute-commands 目标。然后你可以使用嵌入式服务器来配置服务器。

<commands>
    <!-- **These are the commands that aren't going through** -->
    <command>embed-server</command>
    <command>/subsystem=logging/root-logger=ROOT:write-attribute(name="level", value="DEBUG") </command>
    <command>/subsystem=logging/console-handler=CONSOLE:write-attribute(name="level", value="DEBUG")</command>
    <command>/subsystem=logging/file-handler=debug:add(level=DEBUG,autoflush=true,file={"relative-to"=>"jboss.server.log.dir", "path"=>"debug.log"})</command>
    <command>/subsystem=logging/logger=org.jboss.as:add(level=DEBUG,handlers=[debug])</command>
    <command>/subsystem-----Enable Remote access here?</command>
    <command>stop-embedded-server</command>
</commands>