码迷,mamicode.com
首页 > 移动开发 > 详细

java service wrapper日志参数设置及优化

时间:2017-02-04 11:01:47      阅读:1163      评论:0      收藏:0      [点我收藏+]

标签: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日志参数设置及优化

标签:iso   max   tput   ice   ons   contains   efault   自己   use   

原文地址:http://www.cnblogs.com/zhjh256/p/6364119.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!