Cross-platform log cleaning tool Log-Cutter v1.0.3 officially released

    Log-Cutter is a simple and practical log cutting and cleaning tool developed by the JessMA open source organization . For the daily maintenance of the server, log cleaning is very important. If there are too many residual logs, it will seriously waste disk space and affect the performance of the service. Manual cleaning would take too much time, and many times it would be difficult to meet the actual requirements. For example: how to cut log files over 2G at 3 am every Saturday and keep the latest 100M log records? I couldn't find a log cutting tool online that could meet the requirements of this seat, so I spent some spare time writing one myself. Since it is to be used on multiple platforms, it is implemented in Java for convenience. This tool is named Log-Cutter and has the following features :

  1. Supports all common OS platforms including Linux, Mac and Windows
  2. Support command line interactive operation
  3. Support background non-interactive running (implemented by daemon process under Linux/MAC, implemented by system Service in Windows)
  4. Supports two log cleaning methods (deleting log files or cutting log files)
  5. Supports cutting common log file types such as GB18030, UTF-8, UTF-16LE, UTF-16BE, etc.
  6. Highly configurable (program execution cycle, log file expiration time to be deleted, log file threshold to be cut and retention size, etc. can be configured
  • Instructions:
**************************************************************
**** LogCutter - JessMA Open Source, all rights reserved. ****
**************************************************************

1. Startup method
--------------------------------------------------
1) Windows
 A) Foreground run: > ./run.bat [ -f config-file ]
 B) Background operation: > LogCutter.exe {
                                     -install-demand (install manual start service)
                                     -install-auto (install autostart service)
                                     -uninstall (remove service)
                                     -start (start service)
                                     -stop (stop service)
                                     -status (view service status)
                                 }

         *** Note*** 
         @ LogCutter.exe runs as a Windows system service, and can also be managed through the Windows Service Manager after installation
         @LogCutter.exe is a 32-bit program, LogCutter_x64.exe is a 64-bit program, use one of these as needed
         @LogCutter.exe depends on JRE 1.6, so %JAVA_HOME% must be set in registry or environment variable

2) Linux / Unix
 A) Foreground run: $ ./run.sh [ -f config-file ]
 B) Background run: $ ./run.sh [ -f config-file ] -d

         *** Note***
         @ can be set to automatically run in the background when booting, as follows:
             $ vi /etc/rc.d/rc.local  ( 加入: ${YOUR_LOGCUTTER_PATH}/run.sh -d )
 
--------------------------------------------------

2. Configuration file
--------------------------------------------------
1) Program configuration file: ./conf/config.xml (default)
2) Log configuration file: ./conf/log4j.properties (default)
--------------------------------------------------

3. Environmental requirements
--------------------------------------------------
1) Java version: JRE 1.6 or above
2) Dependent packages: dom4j, log4j, juniversalchardet
--------------------------------------------------

4. Operation guide
--------------------------------------------------
Reference: " Operation Guide "
  • configuration file
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
	<global>
		<!-- Start log check delay (hours), default: 0 (start immediately) -->
		<start-check-delay>1</start-check-delay>
		<!-- log check interval (hours), default: 72 -->
		<check-interval></check-interval>
		<!-- Log4j configuration file, default: ${CLASS_ROOT}/../conf/log4j.properties -->
		<log4j-config-file></log4j-config-file>
		<!-- Program lock, default: ${CLASS_ROOT}/../${APP_NAME}.lock -->
		<lock-file></lock-file>
	</global>
	<!-- 要删除的日志文件列表 -->
	<!-- delete-files.expire: 日志文件过期时间(天), 默认: 90 -->
	<delete-files expire="30">
		<!-- files: 文件名称(不包含目录), 必须填写, 可包含通配符 -->
		<!-- files.path: 文件所在目录, 必须填写, 不能包含通配符 -->
		<file path="D:\LogCutter\logs">LogCutter.log*</file>
		<file path="D:\hMailServer\Logs">*.log</file>
		<file path="D:\Tomcat 6.0\logs">*.log</file>
	</delete-files>
	<!-- 要截断的日志文件列表 -->
	<!-- cut-files.threshold: 日志文件截断阀值(KB), 默认: 10240 -->
	<!-- cut-files.reserve: 日志文件保留内容(KB), 默认: 1024 -->
	<!--
		 <!注!> 'cut-files.reserve' 是保留内容的近似值得, 实际内容按行取整保留
			如下列日志文件内容:
				...... ...... ......
		 		line1: xxxxxxxxxxxxxxxxxxxxx
		 		line2: xxxxxxxxxxPyyyyyyyyyy
		 		line3: zzzzzzzzzzzzzzzzzzzzz
		 		line4: zzzzzzzzzzzzzzzzzzzzz
		 		...... ...... ...... (EOF)
		 	'P'为定位得到的保留起点, 程序实际会在'P'点开始查找下一个换行符,
		 	从该换行符的后一个字符开始保留, 也就是从第三行开始保留到文件末尾
	-->
	<cut-files threshold="10240" reserve="512">
		<file path="D:\Apache2.2\logs">*.log</file>
		<file path="D:\MySQL\MySQL Server 5.1\Datafiles\data">*.err</file>
	</cut-files>
</CONFIG>

Log-Cutter 1.0.3 更新:

1) 程序包路径改为 org.jessma.logcutter.*
2增加 Win64 服务程序 LogCutter_x64.exe
3完善使用帮助文档
4程序代码中加入 License 注释

Functional Logs-Cutting tool implemented by Java
最近提交:
本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处,尊重他人劳动共创开源社区。
转载请注明:文章转载自 开源中国社区  [http://www.oschina.net]
本文标题:跨平台日志清理工具 Log-Cutter v1.0.3 正式发布

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325768307&siteId=291194637