Centralized log management for MongoDB and Log4J

Source: Internet
Author: User
The customer has been working with us for almost a year. As the business grows, machines are also growing. At the beginning, no one focused on how to view logs on multiple machines, at the beginning, there were only two application servers. Now there are 25 GlassFish (webapp) servers and 12 JMS servers for sending and receiving messages, now, you only need to view logs on 30 machines.

The customer has been working with us for almost a year. As the business grows, machines are also growing. At the beginning, no one focused on how to view logs on multiple machines, at the beginning, there were only two application servers. Currently, there are 25 GlassFish (web app) servers and 12 JMS servers/message sending and receiving servers, now, you only need to view logs on 30 machines.

The customer has been working with us for almost a year. As the business grows, machines are also growing. At the beginning, no one focused on how to view logs on multiple machines, at the beginning, there were only two application servers. Currently, there are 25 GlassFish (web app) servers and 12 JMS servers/message sending and receiving servers, now the 30 machines are busy simply viewing logs. Just like you open 30 windows on your computer and you need to view logs one by one. Can you say that you can't get a cup of cake?

There are more than 30 machines in the future, but we need to check the running status of Java programs on each machine, if the same method does not seem feasible as before, you need to think about other methods.
Therefore, three solutions are proposed:
1. Write data directly to the database through the Log4J JDBC plug-in,
2. Use the Log4J JMS plug-in to send messages to the JMS server first. After receiving the messages, the JMS server then writes the messages to the database.
3. Write Data to the MongoDB database through the modified Log4J MongoDB plug-in

In this way, we only need to check the log data on one machine to know the running status of each machine. In the future, if we need to analyze the logs, we can perform secondary development and perform operations conveniently, high scalability.

Therefore, we finally chose the third method of writing data to MongoDB. The practices gained from a large number of tests and experiences tell us that MongoDB and MySQL are more effective in the process of executing a large amount of data insertion.

Currently, the following technical architecture is used ,:

Click here to view the big chart

Download the test code,Click here

Related Articles:
MongoDB client tools constantly collect ing (figure)
Ideas about MongoDB Java ORM
Getting started with mongodb
MongoDB Cluster
MongoDB Master/Slave Data Synchronization

Saliva:
I would like to thank Mr. Jozef Sevcik and his open-source project for their inspiration. The code examples provided above have also been sent to Mr. Jozef Sevcik's email address, and soon received his reply, he said in his letter:

Hello H.E,

I'm sorry for delayed response.
Thank you for your contribution, I'm gglad to see people using the project are contributing code back, great!

I'll review your changes during this weekend and let you know,

Thanks,
Jozef

This foreign friend spoke very politely.

-End-

Original article address: centralized log management between MongoDB and Log4J. Thanks to the original author for sharing.

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.