Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSC307 Lecture 10

CSC307 Lecture 10

Introduction to Software Engineering
Logging Process
(202407)

In this lecture, we focus on logging practices and exemplify using SLF4J Logback. We cover configuring logging, understanding severity levels, and best practices for application maintenance. Further, we explore cloud-based log management with BetterStack and revisit Maven for project setup and dependency management.

Source code available at https://github.com/CSC3100/Tool-Logging/

Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.info o ffi ce: 14 -227

    CSC 307 Introduction to Software Engineering Lecture 10. Logging Process
  2. Logging • Recording events, a ctions, or mess a ges

    th a t occur during the execution of a progr a m. • Proper logging is essenti a l for m a int a ining a nd troubleshooting a pplic a tions e ff ectively throughout their lifecycle. 12
  3. SLF4J Logback • St a nds for Simple Logging F

    a c a de for J a v a • It provides a uni f ied interf a ce for logging oper a tions, a llowing developers to write logging code without binding their a pplic a tion to a speci f ic logging implement a tion. • We need to t a lk a bout the F a c a de P a ttern 14
  4. We want this 20 message 01 message 02 message 03

    message 04 message 05 trace() debug() info () warn () error() Logger 20
  5. Resources Folder • The resources folder in a M a

    ven project stores non-source-code f iles th a t your a pplic a tion needs, such a s con f igur a tion f iles, property f iles, im a ges, a nd other resources. • These f iles a re included in the f in a l build output a nd a v a il a ble on the cl a ssp a th a t runtime. 22
  6. src/main/resources/logback.xml • logb a ck.xml is a con f igur

    a tion f ile for SLF4J Logb a ck. • It de f ines how logging should be h a ndled, including log levels, a ppenders (where logs a re written), a nd log form a ts. • When your a pplic a tion st a rts, SLF4J Logb a ck a utom a tic a lly looks for this con f igur a tion f ile. 23
  7. ConsoleAppender 24 message 01 message 02 message 03 message 04

    message 05 trace() debug() info () warn () error() Logger 24 Appender
  8. ConsoleAppender 27 message 01 message 02 message 03 message 04

    message 05 trace() debug() info () warn () error() Logger 27 Appender
  9. Logstash Logback Encoder | POM.xml • Let’s use a nother

    libr a ry to t a ke a dv a nt a ge of extr a encoders • form a t Spring Boot logs in JSON form a t 29 https://github.com/CSC3100/Tool-Logging
  10. Next 33 trace() debug() info () warn () error() message

    01 message 02 message 03 message 04 message 05 Logger Appender Appender
  11. Next 37 trace() debug() info () warn () error() message

    01 message 02 message 03 message 04 message 05 Logger Appender
  12. Cloud-Base Log Management • Cloud-b a sed log m a

    n a gement refers to the pr a ctice of collecting, storing, a n a lyzing, a nd m a n a ging log d a t a using cloud services. • This a ppro a ch lever a ges cloud computing to h a ndle the v a st a mounts of log d a t a 38
  13. SLF4J Logback | Add the dependency 44 Just for JSON

    Support https://github.com/CSC3100/Tool-Logging
  14. Full Solution 51 trace() debug() info () warn () error()

    message 01 message 02 message 03 message 04 message 05 Logger Appender Appender Appender
  15. CSC 307 Introduction to Software Engineering Javier Gonzalez-Sanchez, Ph.D. [email protected]

    Summer 2024 Copyright. These slides can only be used as study material for the class CSC307 at Cal Poly. They cannot be distributed or used for another purpose.