Git Product home page Git Product logo

spring-boot-log4j2's Introduction

README

spring-boot-log4j2 is a repository that includes a spring boot log4j2 logging facade example

What is this repository for?

  • spring boot log4j2

Who do I talk to?

How do I get set up?

  • Check out (clone) git repository
  • Install java 8
  • Import as maven project into your IDE, ensure your settings.xml file is correct
  • -Dspring.profiles.active=dev
  • Run SpringBootLog4j2Application

Console results

  • [2019-06-12 17:17:43,864 DEBUG SpringBootLog4j2Application.main] Debug log message
  • [2019-06-12 17:17:43,868 INFO SpringBootLog4j2Application.main] Info log message
  • [2019-06-12 17:17:43,868 WARN SpringBootLog4j2Application.main] Warning log message
  • [2019-06-12 17:17:43,869 ERROR SpringBootLog4j2Application.main] Error log message
  • [2019-06-12 17:17:43,869 FATAL SpringBootLog4j2Application.main] Fatal log message

Fle configuration

In the log4j2.xml set your rolling file on line 23 to be

  • (windows) <RollingFile name = "File" fileName="C:${path}/${filename}.log" filePattern="C:${path}/${archive}"

You can find the log file at C:/rlawlor/dev/spring-boot/log4j2.log

  • (unix or linux) <RollingFile name ="File" fileName="${sys:user.home}${path}/${filename}.log"filePattern="${sys:user.home}${path}/${archive}">

You can find the log file at /home/username/rlawlor/dev/spring-boot/log4j2.log

File results

  • [2019-06-12 17:31:04,305 DEBUG SpringBootLog4j2Application.main] Debug log message
  • [2019-06-12 17:31:04,309 INFO SpringBootLog4j2Application.main] Info log message
  • [2019-06-12 17:31:04,309 WARN SpringBootLog4j2Application.main] Warning log message
  • [2019-06-12 17:31:04,309 ERROR SpringBootLog4j2Application.main] Error log message
  • [2019-06-12 17:31:04,310 FATAL SpringBootLog4j2Application.main] Fatal log message

Changing log facades

  • In order to test the different log4j2 patterns
  • In the log4j2.xml on line 19 and 23 change the default_with_method option to default or verbose
  • Now re-run your spring boot application and these patterns can be viewed and tested

Changing log levels

  • The log hierarchy is

  • ALL < TRACE < DEBUG < INFO <WARN <ERROR <FATAL <OFF

  • In the log4j2.xml set your root level on line 34 to be INFO for example

  • Now INFO, WARN, ERROR and FATAL are what's available

spring-boot-log4j2's People

Contributors

deepsea avatar

Stargazers

 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.