有没有办法将日志配置(standalone.xml 中介于 和 之间的所有标签)从给定的 Jboss7 服务器复制到另一个服务器?这是为了在所有服务器上拥有完全相同的日志记录配置?由于standalone.xml 是由JBoss7 动态修改的,因此无法简单地复制standalone.xml,因为我们可能在其他配置子系统中存在差异。
问候,
我建议使用CLI 脚本来配置日志记录。然后,您可以使用jboss-cli.sh
(或.bat
用于 Windows)运行脚本。
日志记录配置脚本示例:
# Start batching commands
batch
# Add the periodic rotating file handlers corresponding to those added to the logging properties file
/subsystem=logging/periodic-rotating-file-handler=FILE_QS_WARN:add(suffix=".yyyy.MM.dd", file={"path"=>"quickstart.warn.log", "relative-to"=>"jboss.server.log.dir"})
/subsystem=logging/periodic-rotating-file-handler=FILE_QS_ERROR:add(suffix=".yyyy.MM.dd", file={"path"=>"quickstart.error.log", "relative-to"=>"jboss.server.log.dir"})
/subsystem=logging/periodic-rotating-file-handler=FILE_QS_INFO:add(suffix=".yyyy.MM.dd", file={"path"=>"quickstart.info.log", "relative-to"=>"jboss.server.log.dir"})
/subsystem=logging/periodic-rotating-file-handler=FILE_QS_DEBUG:add(suffix=".yyyy.MM.dd", file={"path"=>"quickstart.debug.log", "relative-to"=>"jboss.server.log.dir"})
/subsystem=logging/periodic-rotating-file-handler=FILE_QS_TRACE:add(suffix=".yyyy.MM.dd", file={"path"=>"quickstart.trace.log", "relative-to"=>"jboss.server.log.dir"})
/subsystem=logging/periodic-rotating-file-handler=FILE_QS_FATAL:add(suffix=".yyyy.MM.dd", file={"path"=>"quickstart.fatal.log", "relative-to"=>"jboss.server.log.dir"})
# Configure the loggin async handler
/subsystem=logging/async-handler=WARN_QS_ASYNC:add(level=WARN,queue-length=1024,overflow-action=BLOCK,subhandlers=["FILE_QS_WARN"])
# Create the logger for our quickstart class, assign the handlers
/subsystem=logging/logger=org.jboss.as.quickstarts.logging:add(level=TRACE)
# Create the logger for our quickstart class, assign the handlers
/subsystem=logging/logger=org.jboss.as.quickstarts.logging:assign-handler(name="WARN_QS_ASYNC")
/subsystem=logging/logger=org.jboss.as.quickstarts.logging:assign-handler(name="FILE_QS_ERROR")
/subsystem=logging/logger=org.jboss.as.quickstarts.logging:assign-handler(name="FILE_QS_INFO")
/subsystem=logging/logger=org.jboss.as.quickstarts.logging:assign-handler(name="FILE_QS_DEBUG")
/subsystem=logging/logger=org.jboss.as.quickstarts.logging:assign-handler(name="FILE_QS_TRACE")
/subsystem=logging/logger=org.jboss.as.quickstarts.logging:assign-handler(name="FILE_QS_FATAL")
# Run the batch commands
run-batch
然后运行脚本,假设名称为 configure-logging.cli,如下所示:
$JBOSS_HOME/bin/jboss-cli.sh --connect --file=configure-logging.cli
注意:在 JBoss AS 7 中有一个错误,上面的脚本需要运行两个批处理。添加记录器后,只需添加一个运行批次和另一个批次。基本上在您将任何处理程序添加到记录器之前。