Using Logmaster4net to implement centralized management of application logs

Source: Internet
Author: User
Tags log4net

The importance of logging in a software system I'm not going to dwell on it here, almost every programmer will have more logs to deal with each day. So have you ever bothered about something like this:

- 远程登录到不同的服务器,找到应用程序目然后查看应用日志;- 来回切换于不同服务器并使用tail来实时监控日志输出信息;- 解决在各个服务器上各个应用日积月累生成的大量日志文件造成的磁盘空间不足的问题;

If there are a lot of different processes in your system and running on multiple servers, the problem above will be particularly prominent. Unfortunately, the author of the company's system, there are dozens of Windows services, console programs, scheduled tasks work simultaneously on multiple servers. Therefore, the author of the disturbance, and finally began to look for the log centralized management solution. Fortunately, an open source log server Software logmaster4net just meet the requirements, and just support the author of the company system used by the log component log4net. After a period of use, Logmaster4net has been in the company stable operation for more than half a year time. The author of the company's diary from this regular, monitoring system operation is more convenient than before, query system operation problems are more rapid.

Here are some ways to use logmaster4net :

Download installation

: https://github.com/kerryjiang/LogMaster4Net/releases/tag/0.1

Configure Port: Open the root directory configuration file (SuperSocket.SocketService.exe.config) to set the port number (default is 2020)

<name= "Logmasterserver"...        Port= "[Port]"...        </server>

Install Windows service: command line run the following instructions, after successful installation, if the discovery service is not started, please find the service Logmaster4netservice in the list of services and start

SuperSocket.SocketService.exe -i
Copy the application's log4net configuration file to the Logmaster4net directory

Logmaster4net can use the app's log profile directly. Application log if you have file generation, note the file save path. The application configuration file should be stored in the Config folder of Logmaster4net, relative to the following path:

\Config\log4net.[LogAppName].Config

[Logappname] is a unique name applied in Logmaster4net and will be used in later settings.

If [Logappname] is "Queryapp", then this app's log profile is named:

\Config\log4net.QueryApp.Config

The log configuration for this app can be:

<?XML version= "1.0" encoding= "Utf-8"?><log4net>    <Appendername= "Infoappender"type= "log4net." Appender.rollingfileappender ">        <Filtertype= "log4net." Filter.levelrangefilter ">            <Levelminvalue= "INFO" />        </Filter>        <filevalue= "Applogs\sampleapp\info.log" />        <encodingvalue= "Utf-8"/>        <preservelogfilenameextensionvalue= "true" />        <Appendtofilevalue= "true" />        <Rollingstylevalue= "Date" />        <Datepatternvalue= "YyyyMMdd" />        <Layouttype= "log4net." Layout.patternlayout ">            <Conversionpatternvalue= "%date [%thread]%-5level%logger-%message%newline" />        </Layout>    </Appender>    <Root>        < Levelvalue= "All" />        <Appender-refref= "Infoappender" />    </Root></log4net>
Application Log Forwarding Settings

To forward logs using Log4net's Udpappender:

<Appendername= "Udpappender"type= "log4net." Appender.udpappender ">  <remoteaddressvalue= "[ServerAddress]" />  <RemotePortvalue= "[Port]" />  <Layouttype= "log4net." Layout.xmllayout ">      <Locationinfovalue= "true" />  </Layout></Appender>
    • [ServerAddress]: Logmaster4net Service installation Run address
    • [Port]: Logmaster4net service monitoring port number;

Set the log global variable "logappname":

log4net.GlobalContext.Properties["LogAppName"] = "QueryApp";

Here Logappname is the unique name "Queryapp" that is applied to the logmaster4net in the preceding step.

After completing the above steps, compiling and running the application, the logs are forwarded to logmaster4net and processed according to the configuration of the application's logs.

Advantages and disadvantages of logmaster4net

The advantages are as follows:

    • Simple: Use the features of the existing log components directly, without the need for additional development;
    • Transparent: The configuration of the original application is still processed, as if the local processing log is applied;
    • Flexible: Flexible Configuration strategy: SuperSocket-based configuration allows logmaster4net to listen to multiple IPs and ports, even allowing you to run multiple logmaster4net server instances;
    • Cross-platform: binary-level compatible unix/linux (via mono); (Http://docs.supersocket.net/v1-6/zh-CN/Run-SuperSocket-in-Linux-Unix)

Disadvantages are also many:

    • Although the various log components are supported on the architecture, their developers only support log4net for the time being;
    • Lack of corresponding log aid tools, such as dashboard, archive; For more advanced functions, it needs to be used in conjunction with other tools;
Prospect

Today's software, Cloud Computing (PaaS), application Containers (Docker), micro-services and other technologies (concepts) more and more widely used. In order to pursue better reliability, stability and maintainability, more systems will be run in multi-process and multi-instance mode in the future. As a basic component in a software system, the centralized management of logs will be a common topic. Related best practices, open source projects will continue to emerge.

The legendary Splunk is very good and powerful, but not cheap. Not all companies (Chinese companies) are willing to put so much money into the journal. Logmaster4net as one of the open-source software is only a small step, but for some less demanding, limited technical strength of the medium-sized it enterprises are enough. But fortunately, Logmaster4net launched a very short time, is a very young open source project, if you have any suggestions for it, may wish to contact its author directly. I believe Logmaster4net will have a good development in the next few years.

Using Logmaster4net to implement centralized management of application logs

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.