JbossEAP日志配置

一、基础内容

1.支持的日志等级

LevelValueDescription
ALLInteger.MIN_VALUEProvides all log messages.(提供所有的日志信息。)
FINEST300-
FINER400-
TRACE400TRACE level log messages provide detailed information about the running state of an application and are usually only captured during debugging.(TRACE 级别的日志提供了应用程序的运行状态的详细信息,它通常用于调试过程。)
DEBUG500DEBUG level log messages indicate the progress of individual requests or application activities and are usually only captured during debugging.(DEBUG 级别的日志指示单独请求或应用程序活动的进展,它通常在调试过程中使用。)
FINE500-
CONFIG700-
INFO800INFO level log messages indicate the overall progress of the application. Often used for application startup, shutdown, and other major lifecycle events.(INFO 级别的日志指示应用程序的总体进展。它通常用于应用程序启动、关闭和其他主要的生命周期事件。)
WARN900WARN level log messages indicate a situation that is not in error, but is not considered ideal. WARN log messages can indicate circumstances that could lead to errors in the future.(WARN 级别的日志信息代表了一个不理相但也不是错误的状况。WARN 日志信息可以指示将来可能导致错误的情况。)
WARNING900-
ERROR1000ERROR level log messages indicate an error that has occurred that could prevent the current activity or request from completing but will not prevent the application from running.(ERROR 级别的日志指示可能阻止当前活动完成但不会阻止应用程序运行的错误已发生。)
SEVERE1000-
FATAL1100FATAL level log messages indicate events that could cause critical service failure and application shutdown and could cause JBoss EAP to shutdown.(FATAL 级别的日志指示可能导致严重服务故障和应用程序关闭以及可能导致 JBoss EAP 关闭的事件。)
OFFInteger.MAX_VALUEDoes not display any log message.(不显示任何日志信息。)

2.日志格式

类型描述
%cThe category of the logging event.(日志事件的类别。)
%pThe level of the log entry (INFO, DEBUG, etc.).(日志条目的级别(INFO、DEBUG 等)。)
%PThe localized level of the log entry.(日志条目的本地化级别。)
%dThe current date/time (yyyy-MM-dd HH:mm:ss,SSS format).(当前的日期/时间(yyyy-MM-dd HH:mm:ss,SSS 格式)。)
%rThe relative time (milliseconds since the log was initialized).(相对时间(自日志初始化后的毫秒数)。)
%zThe time zone, which must be specified before the date (%d). For example, %z{GMT}%d{HH:mm:ss,SSS}.(时区,必须在日期(%d)之前指定。例如,%z{GMT}%d{HH:mm:ss,SSS}。)
%kA log resource key (used for localization of log messages).(日志资源关键字(用于日志信息的本地化)。)
%mThe log message (including exception trace).(日志信息(包含异常跟踪信息)。)
%sThe simple log message (no exception trace).(简单日志信息(不包含异常跟踪信息)。)
%eThe exception stack trace (no extended module information).(异常栈跟踪信息(不包含扩展的模块信息)。)
%EThe exception stack trace (with extended module information).(异常栈跟踪信息(包含扩展的模块信息)。)
%tThe name of the current thread.(当前线程的名称。)
%nA newline character.(换行符。)
%CThe class of the code calling the log method (slow).(调用日志方法(慢)的代码的类。)
%FThe filename of the class calling the log method (slow).(调用日志方法(慢)的类的文件名。)
%lThe source location of the code calling the log method (slow).(调用日志方法(慢)的代码的源码位置。)
%LThe line number of the code calling the log method (slow).(调用日志方法(慢)的代码的行号。)
%MThe method of the code calling the log method (slow).(调用日志方法(慢)的代码的方法。)
%xThe Nested Diagnostic Context.(嵌套的诊断性上下文。)
%XThe Message Diagnostic Context.(消息诊断性上下文。)
%%A literal percent (%) character (escaping)(百分比(%)字符(脱字符)。).

3.过滤器

过滤标签描述
acceptAccept all log messages.(接受所有的日志信息。)
denyDeny all log messages.(拒绝所有的日志信息。)
not[filter expression]Returns the inverted value of a single filter expression.(返回单个过滤器表达式的反转值) For example:not(match(“WFLY”))
all[filter expression]Returns concatenated value from a comma-separated list of filter expressions.(返回连接用逗号隔开的过滤器表达式的值) For example:all(match(“WFLY”),match(“WELD”))
any[filter expression]Returns one value from a comma-separated list of filter expressions.(从用逗号隔开的过滤器表达式列表返回一个值) For example:any(match(“WFLY”),match(“WELD”))
levelChange[level]Updates the log record with the specified level. (用指定的级别更新日志记录)For example:levelChange(WARN)
levels[levels]Filters log messages with a level listed in the comma-separated list of levels. (过滤用逗号隔开的级别列表里列出的级别的日志信息)For example:levels(DEBUG,INFO,WARN,ERROR)
levelRange[minLevel,maxLevel]Filters log messages within the specified level range. The [ and ] characters are used to indicate an inclusive level. The ( and ) characters are used to indicate an exclusive level.(过滤指定日志级别范围内的日志信息。[ 和 ] 字符用来表示包含的级别。( 和 ) 字符则用来表示排斥的级别) For example:levelRange[INFO,ERROR] The minimum level must be greater than or equal to INFO and the maximum level must be less than or equal to ERROR. levelRange[DEBUG,ERROR) The minimum level must be greater than or equal to DEBUG and the maximum level must be less than ERROR.
match[“pattern”]Filters log messages using the provided regular expression.(过滤使用提供的常规表达式的日志信息) For example:match(“WFLY\d+”)
substitute[“pattern”,“replacement value”]A filter that replaces the first match to the pattern (first argument) with the replacement text (second argument).(用替代文本(第二个参数)替换模式的第一次匹配(第一个参数)的过滤器) For example:substitute(“WFLY”,“EAP”)
substituteAll[“pattern”,“replacement value”]A filter which replaces all matches of the pattern (first argument) with the replacement text (second argument). (用替代文本(第二个参数)替换模式的所有匹配(第一个参数)的过滤器)For example:substituteAll(“WFLY”,“EAP”)

二、日志类型

1.Console log handler

(1)含义

日志处理程序将日志信息写入到主机操作系统的标准输出(stdout)或标准错误(stderr)。

(2)标签

标签描述
autoflush如果设置为 true,日志消息将被发送至处理程序接收时立即分配的文件。
enabled如果设置为 true,处理程序被启用且正常工作。如果设置为 false,处理日志消息时处理程序将被忽略。
encoding用于输出的字符编码模式。
filter定义简单的过滤器类型。已弃用,转而使用 filter-spec。
filter-spec定义过滤器的表达式。下面的表达式定义了不匹配某个模式的过滤器:not(match(“WFLY.*”))
formatter这个日志处理程序使用的日志格式器。
level日志处理程序记录的日志消息的最低级别。
name日志处理程序的名称。已弃用(处理程序的地址里已包含这个名称)
named-formatter处理程序使用的格式器的名称。
target日志处理程序输出所在的系统输出流。对于系统错误流和标准输出流,它分别是 System.err 和 System.out。

(3)例子

<console-handler name="CONSOLE">
    <level name="DEBUG"/>
    <formatter>
        <named-formatter name="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
    </formatter>
</console-handler>

2.File log handler

(1)含义

日志处理程序将日志信息写入到指定的文件。

(2)标签

标签描述
append如果设置为 true,这个处理程序写入的所有消息都将附加到这个文件(如果存在)。如果设置为 false,每次应用服务器启动时都会创建一个新的文件。
autoflush如果设置为 true,日志消息将被发送至处理程序接收时立即分配的文件。
enabled如果设置为 true,处理程序被启用且正常工作。如果设置为 false,处理日志消息时处理程序将被忽略。
encoding用于输出的字符编码模式。
file代表这个日志处理程序输出写入的文件的对象。它有两个配置属性:relative-to 和 path。
filter定义简单的过滤器类型。已弃用,转而使用 filter-spec。
filter-spec定义过滤器的表达式。下面的表达式定义了不匹配某个模式的过滤器:not(match(“WFLY.*”))
formatter这个日志处理程序使用的日志格式器。
level日志处理程序记录的日志消息的最低级别。
name日志处理程序的名称。已弃用(处理程序的地址里已包含这个名称)
named-formatter处理程序使用的格式器的名称。

3.Periodic rotating log handler

(1)含义

日志处理程序将日志信息写入到某个命名文件,直至超过指定的时间。超时后文件将按照指定的时间戳重命名,而日志处理程序则继续写入到新创建的具有原来名称的日志文件。

(2)标签

标签描述
append如果设置为 true,这个处理程序写入的所有消息都将附加到这个文件(如果存在)。如果设置为 false,每次应用服务器启动时都会创建一个新的文件。
autoflush如果设置为 true,日志消息将被发送至处理程序接收时立即分配的文件。
enabled如果设置为 true,处理程序被启用且正常工作。如果设置为 false,处理日志消息时处理程序将被忽略。
encoding用于输出的字符编码模式。
file代表这个日志处理程序输出写入的文件的对象。它有两个配置属性:relative-to 和 path。
filter定义简单的过滤器类型。已弃用,转而使用 filter-spec。
filter-spec定义过滤器的表达式。下面的表达式定义了不匹配某个模式的过滤器:not(match(“WFLY.*”))。
formatter这个日志处理程序使用的日志格式器。
level日志处理程序记录的日志消息的最低级别。
name日志处理程序的名称。已弃用(处理程序的地址里已包含这个名称)
named-formatter处理程序使用的格式器的名称。
suffix这个字符串包含在轮换日志的后缀里。suffix 的格式是句点(.)后面跟着 SimpleDateFormat 可以解析的日期字符串。

(3)例子

<periodic-rotating-file-handler name="FILE" autoflush="true">
    <formatter>
        <named-formatter name="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
    </formatter>
    <file relative-to="jboss.server.log.dir" path="file.log"/>
    <!-- 每100M就新建一个新的文件 -->
    <rotate-size value="100M"/>
    <!-- 一共保存150个文件,超过150个就将最早的替换掉 -->
    <max-backup-index value="150"/>
    <!-- 后缀为年与日,例如2019-09-18,如果不是最新的日志,则文件名为xxx.log.2019-09-18.1 -->
    <suffix value=".yyyy-MM-dd"/>
    <append value="true"/>
</periodic-rotating-file-handler>

4.Size rotating log handler

(1)含义

处理程序将日志信息写入到某个命名文件,直至文件达到指定的大小。此时,文件将用一个数字后缀重命名,而日志处理程序则继续写入到新创建的具有原来名称的日志文件。每个 Size 日志处理程序都必须指定保持这种形式的最大文件数量。

(2)标签

标签描述
append如果设置为 true,这个处理程序写入的所有消息都将附加到这个文件(如果存在)。如果设置为 false,每次应用服务器启动时都会创建一个新的文件。
autoflush如果设置为 true,日志消息将被发送至处理程序接收时立即分配的文件。
enabled如果设置为 true,处理程序被启用且正常工作。如果设置为 false,处理日志消息时处理程序将被忽略。
encoding用于输出的字符编码模式。
file代表这个日志处理程序输出写入的文件的对象。它有两个配置属性:relative-to 和 path。
filter定义简单的过滤器类型。已弃用,转而使用 filter-spec。
filter-spec定义过滤器的表达式。下面的表达式定义了不匹配某个模式的过滤器:not(match(“WFLY.*”))
formatter这个日志处理程序使用的日志格式器。
level日志处理程序记录的日志消息的最低级别。
max-backup-index轮换日志文件保留的最大数目。当到达这个数目时,最旧的日志文件将被重用。默认为 1。如果使用了 suffix 属性,轮换日志文件的后缀将包含在轮换算法里。当轮换日志文件时,以 name+suffix 开始的最旧的文件将被删除,剩余的轮换日志文件的数字型后缀都会增加,而最近轮换的日志文件的后缀将是 1。
name日志处理程序的名称。已弃用(处理程序的地址里已包含这个名称)
named-formatter处理程序使用的格式器的名称。
rotate-on-boot如果设置为 true,新的日志文件将服务器重启时创建。默认是 false。
rotate-size日志文件在轮换前可到达的最大尺寸。数字后的单个字符表示单位:b 为字节、 k 为千字节、 m 为兆字节,而 g 为千兆字节。例如 50m 表示 50MB。
suffix这个字符串包含在轮换日志的后缀里。suffix 的格式是句点(.)后面跟着 SimpleDateFormat 可以解析的日期字符串。

(3)例子

<size-rotating-file-handler name="FILE">
    <formatter>
        <pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
    </formatter>
    <file relative-to="jboss.server.log.dir" path="file.log"/>
    <rotate-size value="100m"/>
    <max-backup-index value="100"/>
    <append value="true"/>
</size-rotating-file-handler>

5.Periodic size rotating log handler

(1)含义

日志处理程序将日志信息写入到某个命名文件,直至文件达到指定的大小或 超过指定的时间。此时,文件将重命名,而日志处理程序则继续写入到新创建的具有原来名称的日志文件。

(2)标签

标签描述
append如果设置为 true,这个处理程序写入的所有消息都将附加到这个文件(如果存在)。如果设置为 false,每次应用服务器启动时都会创建一个新的文件。
autoflush如果设置为 true,日志消息将被发送至处理程序接收时立即分配的文件。
enabled如果设置为 true,处理程序被启用且正常工作。如果设置为 false,处理日志消息时处理程序将被忽略。
encoding用于输出的字符编码模式。
file代表这个日志处理程序输出写入的文件的对象。它有两个配置属性:relative-to 和 path。
filter-spec定义过滤器的表达式。下面的表达式定义了不匹配某个模式的过滤器:not(match(“WFLY.*”))
formatter这个日志处理程序使用的日志格式器。
level日志处理程序记录的日志消息的最低级别。
max-backup-index轮换日志文件保留的最大数目。当到达这个数目时,最旧的日志文件将被重用。默认为 1。如果使用了 suffix 属性,轮换日志文件的后缀将包含在轮换算法里。当轮换日志文件时,以 name+suffix
name日志处理程序的名称。已弃用(处理程序的地址里已包含这个名称)
named-formatter处理程序使用的格式器的名称。
rotate-on-boot如果设置为 true,新的日志文件将服务器重启时创建。默认是 false。
rotate-size日志文件在轮换前可到达的最大尺寸。数字后的单个字符表示单位:b 为字节、 k 为千字节、 m 为兆字节,而 g 为千兆字节。例如 50m 表示 50MB。
suffix这个字符串包含在轮换日志的后缀里。suffix 的格式是句点(.)后面跟着 SimpleDateFormat 可以解析的日期字符串。

(3)例子

<periodic-size-rotating-file-handler name="FILE" autoflush="true">
    <formatter>
        <named-formatter name="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
    </formatter>
    <file relative-to="jboss.server.log.dir" path="file.log"/>
    <!-- 每100M就新建一个新的文件 -->
    <rotate-size value="100M"/>
    <!-- 一共保存150个文件,超过150个就将最早的替换掉 -->
    <max-backup-index value="150"/>
    <!-- 后缀为年与日,例如2019-09-18,如果不是最新的日志,则文件名为xxx.log.2019-09-18.1 -->
    <suffix value=".yyyy-MM-dd"/>
    <append value="true"/>
</periodic-size-rotating-file-handler>

6.Syslog handler

(1)含义

日志处理程序可以用来发送信息给远程的日志服务器。这允许多个应用程序发送日志信息到相同的服务器,在一起进行解析。

(2)标签

标签描述
app-name当以 RFC5424 格式格式化消息时使用的应用程序名称。默认的应用程序名称是 java。
enabled如果设置为 true,处理程序被启用且正常工作。如果设置为 false,处理日志消息时处理程序将被忽略。
facilityRFC-5424 和 RFC-3164 定义的工具。
hostname发送消息的主机的名称。例如,运行应用服务器的主机的名称。
level日志处理程序记录的日志消息的最低级别。
portsyslog 服务器侦听的端口。
server-addresssyslog 服务器的地址。
syslog-format按照 RFC 规格格式化日志消息。

7.Custom log handler

(1)含义

自定义日志处理程序让您可以配置新的日志处理程序类型。自定义处理程序必须实现为继承 java.util.logging.Handler 的 Java 类且包含在模块里。您也可以将 Log4J appender 用作自定义日志处理程序。

(2)标签

标签描述
class要使用的日志处理程序类。
enabled如果设置为 true,处理程序被启用且正常工作。如果设置为 false,处理日志消息时处理程序将被忽略。
encoding用于输出的字符编码模式。
filter定义简单的过滤器类型。已弃用,转而使用 filter-spec。
filter-spec定义过滤器的表达式。下面的表达式定义了不匹配某个模式的过滤器:not(match(“WFLY.*”))
formatter这个日志处理程序使用的日志格式器。
level日志处理程序记录的日志消息的最低级别。
module日志处理程序依赖的模块。
name日志处理程序的名称。已弃用(处理程序的地址里已包含这个名称)
named-formatter处理程序使用的格式器的名称。
properties用于日志处理程序的属性。

8.Async log handler

(1)含义

日志处理程序是一个日志处理程序 Wrapper,它为一个或多个日志处理程序提供异步行为。它可用于具有高延迟或其他性能问题(如写入日志信息到网络文件系统)的日志处理程序。

(2)标签

标签描述
enabled如果设置为 true,处理程序被启用且正常工作。如果设置为 false,处理日志消息时处理程序将被忽略。
filter定义简单的过滤器类型。已弃用,转而使用 filter-spec。
filter-spec定义过滤器的表达式。下面的表达式定义了不匹配某个模式的过滤器:not(match(“WFLY.*”))
level日志处理程序记录的日志消息的最低级别。
name日志处理程序的名称。已弃用(处理程序的地址里已包含这个名称)
overflow-action当超过队列长度时这个处理程序如何应对。它可以设置为 BLOCK 或 DISCARD。BLOCK 让日志应用程序等待直至队列有可用空间。这和非异步日志处理程序是相同的行为。DISCARD 允许日志处理程序继续,但会删除日志消息。
queue-length在等待子处理程序响应时,这个处理程序保持的日志消息的最大数目。
subhandlers这个异步处理程序将日志消息传入的日志处理程序列表。

参考文献:
https://access.redhat.com/documentation/zh-cn/red_hat_jboss_enterprise_application_platform/7.0/html/configuration_guide/logging_with_jboss_eap

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
deploy/jbossweb-tomcat55.sar/server.xml <Valve className="org.apache.catalina.valves.FastCommonAccessLogValve" prefix="access_log." suffix=".log" pattern="%h %t %r %s %D" directory="${jboss.server.home.dir}/../output/logs" resolveHosts="false" /> http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html pattern配置: %a - Remote IP address %A - Local IP address %b - Bytes sent, excluding HTTP headers, or '-' if zero %B - Bytes sent, excluding HTTP headers %h - Remote host name (or IP address if resolveHosts is false) %H - Request protocol %l - Remote logical username from identd (always returns '-') %m - Request method (GET, POST, etc.) %p - Local port on which this request was received %q - Query string (prepended with a '?' if it exists) %r - First line of the request (method and request URI) %s - HTTP status code of the response %S - User session ID %t - Date and time, in Common Log Format %u - Remote user that was authenticated (if any), else '-' %U - Requested URL path %v - Local server name %D - Time taken to process the request, in millis %T - Time taken to process the request, in seconds %I - current request thread name (can compare later with stacktraces) There is also support to write information from the cookie, incoming header, outgoing response headers, the Session or something else in the ServletRequest. It is modeled after the apache syntax: %{xxx}i for incoming request headers %{xxx}o for outgoing response headers %{xxx}c for a specific request cookie %{xxx}r xxx is an attribute in the ServletRequest %{xxx}s xxx is an attribute in the HttpSession The shorthand pattern name common (which is also the default) corresponds to '%h %l %u %t "%r" %s %b'.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Doubletree_lin

老板,爱你,么么哒

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值