Giter Site home page Giter Site logo

chakra-coder / log-alert-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from abnerrolim/log-alert-example

0.0 1.0 0.0 13 KB

An example using spring-boot to throws alerts by smtp (or any configured appender) using s4lj and l4j2 when logged with specific marker.

Java 100.00%

log-alert-example's Introduction

log-alert-example

A very simple PoC using spring-boot, Slf4j and l4j2 to create alerts when any log is called using a specific mark. In this project alerts will be sent by email, but any appender can be used (Kafka, Http, etc).

A possible scenario can be proactive alerts to dev team when a severe error occur, like database connection failure and so on.

Components

  • MDCFilter: shows the use of Slf4j MDC to log context across request
  • LogUtils: just a standard mark builder
  • Controller: Dummy REST controller simulating business layers.
  • log4j2-spring.xml: configurations

Start

  1. Inject into enviroment the variables to STMPAppender's configuration:

    • receipients
    • from
    • smtpHost
    • smtpPort
    • smtpUser
    • smtpProtocol
    • smtpPassword
  2. Start log-alert-example.jar

  3. Call http://localhost:8080/log-alert/log/{severe} where {severe} is just a boolean to simulate a severe error log.

If all configs are correct an email will arrive as bellow:

28-02-2018 17:14:26,819 INFO  br.org.test.Application context:{} Starting Application on abner-pc with PID 17745 (/home/workspace/log-alert-example/target/classes started by abner in /home/workspace/log-alert-example)
28-02-2018 17:14:26,822 INFO  br.org.test.Application context:{} No active profile set, falling back to default profiles: default
28-02-2018 17:14:28,383 INFO  br.org.test.Application context:{} Started Application in 2.554 seconds (JVM running for 3.166)
28-02-2018 17:14:33,972 ERROR br.org.test.controller.Controller context:{x-global-id=933a4b7e-698d-45bd-b169-b15707e47371} A disaster has occurred into system. Alert support team, please

log-alert-example's People

Contributors

abnerrolim 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.