Slide 1

Slide 1 text

Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.info o ffi ce: 14 -227 CSC 305 Individual Software Design and Development Lecture 15. Logger

Slide 2

Slide 2 text

Assignment 03

Slide 3

Slide 3 text

3 Assignment 03 is due on Friday November 14

Slide 4

Slide 4 text

Assignment 03 4

Slide 5

Slide 5 text

Assignment 03 | Example 1 | Tab 1 5 Bo a rdP a nel M a in Controller M a in01.j a v a Take the population values and divide them into three groups by first finding the largest and smallest values, then calculating the range between them, and finally using that range to set two cut- off points.

Slide 6

Slide 6 text

Assignment 03 | Example 1 | Tab 2 6 Painful Useless Controller Main BoardPanel * java files colors to be calculated; * not showing them here Add inheritance and local variables, but only for the other classes in this folder

Slide 7

Slide 7 text

Assignment 03 | Example 1 | Tab 3 7 👷 This space is empty for now

Slide 8

Slide 8 text

Logging

Slide 9

Slide 9 text

Problem 9

Slide 10

Slide 10 text

Bad Idea System.out.println 10 Messages

Slide 11

Slide 11 text

Good Idea 11 message 01 message 02 message 03 message 04 message 05

Slide 12

Slide 12 text

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 12

Slide 13

Slide 13 text

SLF4J Logback | Add the dependency 13 https://github.com/CSC3100/Tool-Logging

Slide 14

Slide 14 text

SLF4J Logback | Logging 14 https://github.com/CSC3100/Tool-Logging

Slide 15

Slide 15 text

We want this 15 message 01 message 02 message 03 message 04 message 05 trace() debug() info () warn () error() Logger 15

Slide 16

Slide 16 text

Next

Slide 17

Slide 17 text

Maven File and Directories 17

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

ConsoleAppender 20 message 01 message 02 message 03 message 04 message 05 trace() debug() info () warn () error() Logger 20 Appender

Slide 21

Slide 21 text

src/main/resources/logback.xml 21 https://github.com/CSC3100/Tool-Logging

Slide 22

Slide 22 text

SLF4J Logback | Logging 22

Slide 23

Slide 23 text

ConsoleAppender 23 message 01 message 02 message 03 message 04 message 05 trace() debug() info () warn () error() Logger 23 Appender

Slide 24

Slide 24 text

FileAppender

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

src/main/resources/logback.xml 26 https://github.com/CSC3100/Tool-Logging

Slide 27

Slide 27 text

SLF4J Logback | Logging 27

Slide 28

Slide 28 text

Cloud-Based Log Management

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

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 30

Slide 31

Slide 31 text

betterstack.com/logs 31

Slide 32

Slide 32 text

We need keys 32 String key = "XYZabc123259#$%#$Fcaskjhdux_2342445Calp";

Slide 33

Slide 33 text

betterstack.com/logs 33

Slide 34

Slide 34 text

betterstack.com/logs 34 WE6x9ya1dfMwRTouP9DEBmg

Slide 35

Slide 35 text

HttpAppender Our very own creation Just for fun

Slide 36

Slide 36 text

SLF4J Logback | Add the dependency 36 Just for JSON Support https://github.com/CSC3100/Tool-Logging

Slide 37

Slide 37 text

src/main/resources/logback.xml 37 WE6x9ya1dfMwRTouP9DEB https://github.com/CSC3100/Tool-Logging

Slide 38

Slide 38 text

javiergs.HttpAppender (Part 1/4) 38 https://github.com/CSC3100/Tool-Logging

Slide 39

Slide 39 text

javiergs.HttpAppender (Part 2/4) 39 https://github.com/CSC3100/Tool-Logging

Slide 40

Slide 40 text

javiergs.HttpAppender (Part 3/4) 40 https://github.com/CSC3100/Tool-Logging

Slide 41

Slide 41 text

javiergs.HttpAppender (Part 4/4) 41 https://github.com/CSC3100/Tool-Logging

Slide 42

Slide 42 text

logs.betterstack.com 42

Slide 43

Slide 43 text

Full Solution 43 trace() debug() info () warn () error() message 01 message 02 message 03 message 04 message 05 Logger Appender Appender Appender

Slide 44

Slide 44 text

Encoder

Slide 45

Slide 45 text

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 45 https://github.com/CSC3100/Tool-Logging

Slide 46

Slide 46 text

src/main/resources/logback.xml 46 https://github.com/CSC3100/Tool-Logging

Slide 47

Slide 47 text

SLF4J Logback | Logging 47

Slide 48

Slide 48 text

Questions 48

Slide 49

Slide 49 text

Lab

Slide 50

Slide 50 text

50

Slide 51

Slide 51 text

CSC 305 Individual Software Design and Development Javier Gonzalez-Sanchez, Ph.D. [email protected] Fall 2025 Copyright. These slides can only be used as study material for the class CSC305 at Cal Poly. They cannot be distributed or used for another purpose.