1

我正在使用 Wildfly Maven 插件,它正在工作,因为它打开,运行 Web 应用程序,但是我的自定义配置有问题,即:

  • 将根记录器和控制台记录器设置为调试模式
  • 允许来自0.0.0.0:8080本地主机或其他主机的连接。

这是我的设置:

<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然后手动将日志记录从默认信息级别更改为调试:

手动更改日志记录级别的图像

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

4

1 回答 1

1

您需要将插件版本升级到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>
于 2020-02-26T09:13:38.827 回答