標籤:iso max tput ice ons contains efault 自己 use
一般在容器比如tomcat/weblogic中運行時,我們都是通過log4j控制日誌輸出的,因為我們現在很多服務端使用java service wrapper(至於為什麼使用jsw,原先是比較排斥使用的,但是當一台伺服器上部署10來個應用時,我們無條件的選擇了jsw,因為不需要折騰和規劃這麼多的連接埠了,尤其是我們還是自己的RPC時,每個應用的連接埠需求從4個變成了1個)進行啟動和管理,而JSW還有自己的日誌格式,可以說在log4j上又套了一層馬甲,預設的日誌格式並不是輸出原始log4j資訊,因為我們已經使用log4j管理了,所以不再需要JSW的馬甲,其通過如下參數控制日誌格式、大小以及滾動。
# Format of output for the console. (See docs for formats)wrapper.console.format=PM# Log Level for console output. (See docs for log levels)wrapper.console.loglevel=INFO# Log file to use for wrapper output logging.wrapper.logfile=../logs/osm-runtime.log# Format of output for the log file. (See docs for formats)wrapper.logfile.format=M# Log Level for log file output. (See docs for log levels)wrapper.logfile.loglevel=INFO# Maximum size that the log file will be allowed to grow to before# the log is rolled. Size is specified in bytes. The default value# of 0, disables log rolling. May abbreviate with the ‘k‘ (kb) or# ‘m‘ (mb) suffix. For example: 10m = 10 megabytes.wrapper.logfile.maxsize=10m# Maximum number of rolled log files which will be allowed before old# files are deleted. The default value of 0 implies no limit.wrapper.logfile.maxfiles=100# Log Level for sys/event log output. (See docs for log levels)wrapper.syslog.loglevel=NONE
format的取值如下(貼出來純屬官網依賴google的cdn或嵌入廣告,不FQ開啟實在慢):
Format to use for logging to the log file. Logging has been intentionally kept simple.
The format consists of the following tokens:
- ‘L‘ for log level,
- ‘P‘ for prefix,
- ‘D‘ (Since ver. 3.1.0) for thread,
- ‘T‘ for time,
- ‘Z‘ for millisecond time,
- ‘R‘ quite duration milliseconds showing the time since the previous JVM output,
- ‘U‘ (Since ver. 3.5.0) for approximate uptime in seconds (based on internal tick counter and is valid up to one year from startup),
- ‘G‘ (Since ver. 3.5.8) for time in milliseconds it tool to log the previous log entry (See wrapper.log.warning.threshold for more information),
- ‘W‘ (Since ver. 3.5.30) for the PID of the Wrapper process.
- ‘J‘ (Since ver. 3.5.30) for the PID of the Java process (if the JVM is up).
- ‘M‘ for message.
If the format contains these tokens above, then it will be output with the specified formation. The order of the tokens does not affect the way the log appears, but the ‘M‘ (for message) token should usually be placed last as it is the only column without a uniform width. If the property is missing tokens or commented out, then the default value ‘LPTM‘ will be used.
Logging Disable:
Setting the property to a blank value will cause file logging to be disabled.
wrapper.logfile.format=
設定日誌重新整理間隔:
wrapper.logfile.flush.timeout=min(5,1*進程數)
java service wrapper日誌參數設定及最佳化