Git Product home page Git Product logo

liurui-1 / mmlog Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 0.0 114 KB

Log rotation tool for shell scripts, or any apps which generate logs to standard output or standard error. (Note this is a different project from the joyent/mmlog which is a tool for dumping chat history from a Mattermost chat server.)

License: Apache License 2.0

CMake 1.04% C 41.20% Makefile 57.76%
tomcat-log log-rotation logging

mmlog's Introduction

mmlog

"mmlog" is a simple log rotation tool for shell scripts, or apps which generate logging data to standard output or standard error. "mmlog" is an useful tool to prevent logging data to saturates user's disk.

There is built-in tool named "logrotate" in some systems. But "logrotate" costs too much CPU and cannot control the maximum size of the log file. "mmlog" is much more lightweight, esier configuration, and with more good features for shell scripts, or apps which generate logging data to standard output or standard error.

Build mmlog for your system

"mmlog" binaries for 7 platforms are provided in the "build" folder. You can also build "mmlog" for your own platforms with following command:

make

Syntax to use mmlog:

<cmd> | mmlog
Or:
 mmlog <log-message>

Environment Varibles:

MM_LOGFILE_NUM: Number of log files to rotate. Default is 10.
MM_LOGFILE: Name of the log file. Default is "mmlog"
MM_LOGSIZE: Max size of one log file. Default is 10M.

Samples of usage

  1. Rotate logging data from standard output and error, set logfile name and size to rotate, run in background...
export MM_LOGFILE=myapp
export MM_LOGSIZE=1000000
nohup ./myapp 2>&1 | ./mmlog &
  1. Rotate your Tomcat log

For example your Tomcat installed on Linux/x64 and is located in directory "TOMCAT_HOME=/opt/apache-tomcat-9.0.44". Down mmlog for Linux from page: https://github.com/liurui-1/mmlog/blob/master/build/linux.amd64/mmlog and copy to directory "$TOMCAT_HOME/bin". Use following command to start Tomcat. Then you make your Tomcat log rotated. The major Tomcat log file originally named catalina.out which can grow up to unlimited size,is now named tomcat#.log as 10 rotated log files up to 1M size).

export TOMCAT_HOME=/opt/apache-tomcat-9.0.44
export CATALINA_OUT_CMD="nohup $TOMCAT_HOME/bin/mmlog"
export MM_LOGFILE=$TOMCAT_HOME/logs/tomcat
export MM_LOGSIZE=1000000
$TOMCAT_HOME/bin/startup.sh

mmlog's People

Contributors

liurui-1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.