Use open source software sentry to collect logs

Source: Internet
Author: User
Tags dsn

Original address: http://luxuryzh.iteye.com/blog/1980364

For an already on-line system, there are unknown bugs or the runtime exception is a very common thing, followed by a few needs to produce:
1, if the system is abnormal when the log can be viewed to specific reasons
2, how the first time to catch the exception
3. What anomalies are present in the system?
4, which abnormal occurrence of high frequency
1th good solution, use log4j, Logback and other log framework to print the exception information (stacktrace,params) to the log file, you can easily see the trust information when looking. But this often has a lag, wait until the user feedback or system crashes to go to the online view log to find the reason, may have been sent for several days, the loss is very large. So the 2nd is particularly important, how to do the first time to catch the anomaly? You can tail-f yourlog.log staring at the screen has been seen, the exception is immediately resolved, but the number of logs large, distributed in multiple servers when such a practice will certainly not work, so need to have monitoring measures, the first time alarm. For the third and 4th, it is necessary to classify the anomalies.
So a log collection system prototype sketched out: With the collection of logs (for distributed environment, the log distributed on each server), log statistics (the most statistics of the exception, often this is the hidden danger of the system), monitoring alarm (abnormal or abnormal accumulation to a certain amount of text messages or messages in the form of alarm) , and the visual interface for the above features. In fact, to develop such a system is still difficult, fortunately, there are good open source products can be used directly, this is sentry, a Djongo-based log collection system. Sentry's interface is beautiful, supported by many languages and frameworks, easy to expand, and efficient.
There are many tutorials on the installation and configuration of sentry, which is not very difficult. Sentry is the software of the C/s structure, so the client is needed after the server is deployed, the Sentry client supports Python/php/ruby/java and other languages and supports integration in many frameworks.
Take the Logback integration with Java as an example:
Configure the dependencies of the sentry client in the project's Pom.xml file:
<!--Sentry Raven-java configuration---
Java code
    1. <dependency>
    2. <groupId>net.kencochrane.raven</groupId>
    3. <artifactId>raven-logback</artifactId>
    4. <version>4.1. 1</version>
    5. </dependency>

<!--Jaskson Configuration--
Java code
    1. <dependency>
    2. <groupId>com.fasterxml.jackson.core</groupId>
    3. <artifactId>jackson-core</artifactId>
    4. <version>2.3. 0</version>
    5. </dependency>

<!--Sentry Appender configuration---
Java code
    1. <appender name="Sentry" class="Net.kencochrane.raven.logback.SentryAppender" >
    2. <dsn>
    3. http://your API [email protected] Sentry HOST/4
    4. </dsn>
    5. <filter class="Ch.qos.logback.classic.filter.ThresholdFilter" >
    6. <level>ERROR</level>
    7. </filter>
    8. </appender>

DSN needs to configure the API keys, this in the Sentry project configuration can be obtained, everything is so simple, seamless integration, does not affect the existing log printing, but also help to collect anomalies, statistical anomalies, what a good thing, huh, oh, the following is attached to a sentry system we deployed, Please understand that sensitive information is erased by lines.

Finally, it is necessary to say that, after all, sentry log collection is transmitted over the network (TCP/UDP), resulting in performance loss. So it is not applicable to all the business logs collected to sentry, so there is sentry still need ordinary log, after all, business logic tracking and analysis and so on is inseparable from Log,sentry is only a tool for assistance.
    • View Picture Attachments

Use open source software sentry to collect 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.