First Step for Logging with Log4J2

Modular architecture of Log4J2 — source
Log levels — source
  1. Console Appender — send logs to system console.
  2. File Appender — write logs to a file.
  3. Rolling File Appender — writes logs to a file which rollout based on polices and strategies configured on it.
  4. JDBC Appender — send logs to a relational database.
  • %d{HH:mm:ss.SSS} — outputs the date of the log event in the specified format
  • %t — outputs the thread name
  • %level — displays the log level of the message
  • %msg%n — outputs the log message
10:17:01.107 [main] INFO  com.sample.log4j.practice.Demo - Info
10:17:01.109 [main] ERROR com.sample.log4j.practice.Demo - Error
10:17:01.109 [main] WARN com.sample.log4j.practice.Demo - Warn

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store