Simple Logback Log Collection server

Source: Internet
Author: User

A simple shell that collects multiple services using the Logback jar package, different services use different ports, different instances of the same service use the same port, service name and port mappings are stored in the App.list

App.list, Support # annotations

# app List 

# Asset port at 570x
#asset-www  5701
#asset-api  5702
asset-m     5703
# Asset-admin 5704

# Peer port at 560x
P2p-core    5600

# MS ports at 580x
ms-www
5801 Ms-api      5802

app.sh

#!/bin/sh # auth li_jian@gozap.com # logbackserver #the app name in app.list or value ' all ' appname=$1 applistfile=app. List applen=0 Declare-a an declare-a ap if ["" = "$appname"];then cat <<eof Usage: $ [Options] Options:al L Run all app $appListFile {somename} run the specified app in $appListFile EOF fi if [!-e $appLis Tfile];then echo-e ' app list file $appListFile not exist!\n ' else while read line do if [[$line &amp ;& "${line:0:1}"! = "#"]];then an[$appLen]= ' echo ${line} |
           awk ' {print '} '; ap[$appLen]= ' echo ${line} |
           awk ' {print $} ';
       #echo "${line},${an[$appLen]}" ((applen++)); Fi done < $appListFile if ["" = "$appname"];then echo-e "availble app List: \ n" echo "app Nam E: ${an[*]} All "echo" app Port: ${ap[*]} "echo" "Else Groupadd logback >/dev/null Use
Radd logback-g logback >/dev/null
      Totalruns=0 for ((i=0; i<${#an [@]}; i++);d o #echo "${an[$i]}, $appname" If [["$appname" = "${an[$i]}" | | "$appname" = "All"]];then aname=${an[$i]} aport=${ap[$i]} cmd= "JAVA-CP.:./lib/* Ch. Qos.logback.classic.net.SimpleSocketServer $aport conf/logback-${aname}.xml "su logback-c" $cmd >/dev/nul
            L 2&GT;&AMP;1 & "echo" $cmd ";
        ((totalruns++));

    Fi do echo "Total runs $totalRuns"; Fi fi

Usage:

./app.sh All
./app.sh Asset-m

Lib:
Logback-core-1.1.6.jar
Logback-classic-1.1.6.jar
Slf4j-api-1.7.12.jar
Download Address
http://download.csdn.net/detail/lanmo555/9472772

If a high-availability collection is required, it is recommended to develop failover-socket-appender or directly using LOG4J2 + Kafka + Elasticsearch + Kibana

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.