一般在容器比如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*进程数)

eclipse集成wrapper,可参考http://wrapper.tanukisoftware.com/doc/english/qna-eclipse-integration.html

转载于:https://www.cnblogs.com/zhjh256/p/6364119.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 压缩jar 仓库,java服务安装(一):使用java service wrapper及maven打zip包

    tags: java jsw maven zip 1.概述 使用java开发程序,在windows平台下,一般有web应用,后台服务应用,桌面应用: web应用多数打成war包在web容器(如tomc ...

  4. JSW Java_java服务安装(一):使用java service wrapper及maven打zip包

    1.概述 使用java开发程序,在windows平台下,一般有web应用,后台服务应用,桌面应用: web应用多数打成war包在web容器(如tomcat,jetty等)中运行 桌面应用一般打成jar ...

  5. Java Service Wrapper 使用经验总结

    1. 需求背景和工具简介 1.1 需求背景 最近因为公司需要管理上传的附件,准备把过期的文件夹(我们都是在指定目录下以日期8位来规定文件夹命名)移走进行备份,这时候就需要一个定时任务来进行定时检查文件 ...

  6. java线程池的参数设置

    java线程池的参数设置 在说如何对线程池优化之前重复一下线程的7大参数 corePoolSize: 核心线程数,也是线程池中常驻的线程数,线程池初始化时默认是没有线程的,当任务来临时才开始创建线程去 ...

  7. java service wrapper jar 服务_javaservice wrapper 实现注册服务功能

    2.例子1 a.创建HelloWorld_HOME文件夹,在下面编写例子程序HelloWorld.java public class HelloWorld { public static void m ...

  8. [Java基础]--JVM gc参数设置与分析

    感谢原文链接:http://xstarcd.github.io/wiki/Java/JVM_GC.html JVM gc参数设置与分析 原文: http://hi.baidu.com/i1see1yo ...

  9. Java编程题修院子,了解java虚拟机—JVM相关参数设置(2)

    1.   JVM相关参数设置 JVM相关配置 -XX:+PrintGC 两次次YoungGC,两次FullGC. -XX:+PrintGCDetails 打印GC时的内存,并且在程序结束时打印堆内存使 ...

最新文章

  1. C++ vector的内部实现原理及基本用法
  2. MATLAB机器学习系列-12:蚁群算法优化原理及其matlab实现
  3. 广义Fibonacci数列找循环节
  4. 信息系统项目管理师论文优秀范文_软考 信息系统项目管理师备考指南
  5. 国潮中国风工作学习总结学习PPT模板
  6. 在Windows上编译和调试CoreCLR
  7. 记录一下ListItem类的常用的方法
  8. Android4.4 添加系统属性
  9. mapxtreme2008 7.0错误
  10. unity开发下的C#学习笔记——第四章:鼠标匀速跟随
  11. 使用Visual studio查看exe或DLL文件的依赖项
  12. 微信红包随机数字_微信红包随机算法初探
  13. 网站服务器 80端口吗,你的服务器打开IIS80端口了吗?
  14. 【机器学习详解】KNN分类的概念、误差率及其问题
  15. python使用turtle库绘制一个100长度的十字架_哪个选项能够使用turtle库绘制一个半圆形?...
  16. 基于Kinect Azure的多相机数据采集(一)
  17. OutputFormat类——Hadoop
  18. 黄大成:中国浙江的“盖茨神话”
  19. 【HTML5】网页实用技巧3:将方形图片设置成圆形后,添加圆形虚线边框
  20. 问卷调查系统的设计与实现【源码:文档:教程】

热门文章

  1. 转载--SqlAlchemy ORM 学习
  2. Navicat导出表结构
  3. java多线程同步与死锁,廖雪峰Java11多线程编程-2线程同步-3死锁
  4. python strip_Python3 strip()方法
  5. intel服务器芯片组介绍,Intel芯片组的简介
  6. python异常处理结构_python-异常处理
  7. write up 杂项:telenet
  8. 1039: 二哥的困惑 Ⅱ
  9. 美国西北大学 计算机工程专业排名,美国西北大学优势专业排名榜单最新一览...
  10. android 退出应用没有走ondestory方法,Android退出应用最优雅的方式(改进版)