如何在WildFly域模式下创建日志记录处理程序?

时间:2016-04-17 12:08:33

标签: logging configuration jboss wildfly wildfly-10

通过jboss-cli 独立模式创建日志记录处理程序非常简单:

/subsystem=logging/file-handler=fh1:add(level=INFO, file={"relative-to"=>"jboss.server.log.dir", "path"=>"my-log1.log"})

但是当我尝试对域控制器执行相同操作时,则缺少add选项:

/host=slave01/server=server-one/subsystem=logging/file-handler=fh1:add    (hit tab)

我尝试将日志记录模块添加到slave01 host.xml,以便我可以单独为每个主机添加处理程序:

<extensions>
    <!-- ... -->
    <extension module="org.jboss.as.logging"/>
</extensions>

但这当然失败了:

IllegalStateException: WFLYCTL0385: An attempt was made to register
the non-host capable subsystem 'logging' from extension module
'org.jboss.as.logging' in the host model.

assuming编辑logging.properties文件不是正确的方法。那么我怎么能在域模式下这样做呢?

1 个答案:

答案 0 :(得分:1)

您应该使用private Handler mHandler = new Handler(new Handler.Callback() { @Override public boolean handleMessage(Message msg) { synchronized (NoDelayCountDownTimer.this) { if (mCancelled) { return true; } final long millisLeft = mStopTimeInFuture - SystemClock.elapsedRealtime(); if (millisLeft <= 0 || millisLeft < mCountdownInterval) { onFinish(); } else { long lastTickStart = SystemClock.elapsedRealtime(); onTick(millisLeft); // take into account user's onTick taking time to execute long delay = lastTickStart + mCountdownInterval - SystemClock.elapsedRealtime(); // special case: user's onTick took more than interval to complete, skip to next interval while (delay < 0) { delay += mCountdownInterval; } mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG), delay); } } return true; } });

等内容更新与服务器关联的配置文件