一般在容器比如tomcat/weblogic中运行时,我们都是通过log4j控制日志输出的,因为我们现在很多服务端使用java service wrapper(至于为什么使用jsw,原先是比较排斥使用的,但是当一台服务器上部署10来个应用时,我们无条件的选择了jsw,因为不需要折腾和规划这么多的端口了,尤其是我们还是自己的RPC时,每个应用的端口需求从4个变成了1个)进行启动和管理,而JSW还有自己的日志格式,可以说在log4j上又套了一层马甲,默认的日志格式并不是输出原始log4j信息,因为我们已经使用log4j管理了,所以不再需要JSW的马甲,其通过如下参数控制日志格式、大小以及滚动。

  1. # Format of output for the console. (See docs for formats)
  2. wrapper.console.format=PM
  3.  
  4. # Log Level for console output. (See docs for log levels)
  5. wrapper.console.loglevel=INFO
  6.  
  7. # Log file to use for wrapper output logging.
  8. wrapper.logfile=../logs/osm-runtime.log
  9.  
  10. # Format of output for the log file. (See docs for formats)
  11. wrapper.logfile.format=M
  12.  
  13. # Log Level for log file output. (See docs for log levels)
  14. wrapper.logfile.loglevel=INFO
  15.  
  16. # Maximum size that the log file will be allowed to grow to before
  17. # the log is rolled. Size is specified in bytes. The default value
  18. # of 0, disables log rolling. May abbreviate with the 'k' (kb) or
  19. # 'm' (mb) suffix. For example: 10m = 10 megabytes.
  20. wrapper.logfile.maxsize=10m
  21.  
  22. # Maximum number of rolled log files which will be allowed before old
  23. # files are deleted. The default value of 0 implies no limit.
  24. wrapper.logfile.maxfiles=100
  25.  
  26. # Log Level for sys/event log output. (See docs for log levels)
  27. wrapper.syslog.loglevel=NONE

format的取值如下(贴出来纯属官网依赖google的cdn或嵌入广告,不翻墙打开实在慢):

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.

  1. wrapper.logfile.format=
  2.  
  3. 设置日志刷新间隔:
  1. wrapper.logfile.flush.timeout=min(5,1*进程数)
  2.  
  3. eclipse集成wrapper,可参考http://wrapper.tanukisoftware.com/doc/english/qna-eclipse-integration.html

java service wrapper日志参数设置及优化的更多相关文章

  1. Java Service Wrapper将java程序设置为服务

    有时候我们希望我们java写的程序作为服务注册到系统中,Java Service Wrapper(下面简称wrapper)是目前较为流行的将Java程序部署成Windows服务的解决方案, 本文将讨论 ...

  2. Java Service Wrapper 发布Java程序为Windows服务

    下载Windows版本:https://www.krenger.ch/blog/java-service-wrapper-3-5-37-for-windows-x64/ 转自:F:\java\bhGe ...

  3. java service wrapper 级别为info导致内存剧增直至溢出

    上周,公司某一环境发生java service wrapper内存剧增导致最后被自动killed的情况,经过分析,确定导致java service wrapper(后续简称wrapper)守护进程内存 ...

  4. Java Service Wrapper简介与使用

    在实际开发过程中很多模块需要独立运行,他们并不会以web形式发布,传统的做法是将其压缩为jar包独立运行,这种形式简单易行也比较利于维护,但是一旦服务器重启或出现异常时,程序往往无法自行修复或重启.解 ...

  5. 使用 Java Service Wrapper 启动java后台进程服务

    Java Service Wrapper (http://wrapper.tanukisoftware.com/doc/english/product-overview.html)可以很方便得在各个平 ...

  6. 利用JAVA Service Wrapper把JAVA程序做成windows服务

    今天做了一个读取数据入库的程序.由于读取的数据每天都更新,于是就想把程序做成一个服务,每天定时执行.研究了一下,发现有几种方式可以做.下面我主要记录一下JAVA Service Wrapper方式. ...

  7. 使用Java Service Wrapper在Linux下配置Tomcat应用

    前言 Java Service Wrapper是Tanuki Software的一个产品,可以将Java应用注册成Windows或Linux服务,使其可以随系统开机启动,同时可以监控Java应用的状态 ...

  8. Java Service Wrapper 使用

    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/sinat_26279177/article/details/70807173 1       简介 ...

  9. Java Service Wrapper简介与使用(转)

    本文转自https://www.cnblogs.com/zcy_soft/p/3738947.html,写的非常好,珍藏一下 1. wrapper的意思? wrapper在此处理解为“包装”. 2. ...

随机推荐

  1. HOJ 2156 &POJ 2978 Colored stones(线性动规)

    Colored stones Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1759 Accepted: 829 Descrip ...

  2. 5 Tips for Building a Winning DevOps Culture

    对于企业来说,前途未卜的改变往往很难发生,就像航海一样,重复的往往是久经验证的安全航线,这点在DevOps文化的构建上同样如此.近日,CA Technologies的高级策略师Peter Waterh ...

  3. LoadRunner-迭代和并发设置

    迭代:指运行一次脚本时某段代码块(action)循环执行的次数,串行执行 并发:指同时运行脚本的次数,并行执行(多个用户同时跑) 以下是用例和对应的相关设置 Iterations是在Vuser Gen ...

  4. RSA原理说明

    长度,建议至少1024.模数n(常取默认65537)两边都要用. 指数e,和n一起就是公钥. 指数d,和n一起就是私钥. 质数p和q用于生成密钥对,然后就丢弃不公开. 一.密钥对的生成步骤 1.随机选 ...

  5. 【虫师】【selenium】参数化

    # 1 #coding=utf-8 from selenium import webdriver import os,time source = open("F:\\test\\info.t ...

  6. 2017php经典面试题

    1.PHP语言的一大优势是跨平台,什么是跨平台?一.PHP基础: PHP的运行环境最优搭配为Apache+MySQL+PHP,此运行环境可以在不同操作系统(例如windows.Linux等)上配置,不 ...

  7. const与常量,傻傻分不清楚~

    当数组的长度在运行中才能够确定时,普通的静态数组无法满足要求,此时需要动态数组来实现. 今天突然想,const变量在初始化时可以接受变量的赋值,那么可不可以用它来定义一个静态数组呢?于是有下面的尝试: ...

  8. Centos expect spawn、linux expect 用法

    使用expect实现自动登录的脚本,网上有很多,可是都没有一个明白的说明,初学者一般都是照抄.收藏.可是为什么要这么写却不知其然.本文用一个最短的例子说明脚本的原理.  脚本代码如下:  ###### ...

  9. python3中pymysql模块安装及连接数据库(同‘python安装HTMLTestRunner’)

    https://pypi.org/project/PyMySQL/#files 安装完成之后就是连接数据库了 机器上安装了mysql的数据库,并且已经创建了两张表用于测试 python3连接数据库及删 ...

  10. php开启mbstring扩展并设置支持utf-8编码

    前一段时间使用一个服务的接口,因为调用接口时使用的参数里面有中文,调用接口会出现异常问题,后来才明白是编码不一致的问题.然而,我本地项目开发使用的是utf-8,接口那边也是需要utf-8的,那么问题来 ...