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 16. Services

Slide 2

Slide 2 text

Final Exam 2 a) Thursday December 4 - 12:10 pm - 13:30 pm

Slide 3

Slide 3 text

✅ Logging ✅ Quality Metrics ✅ Dependency Management ✅ Multithreading ✅ User Interfaces++ Week 09 3 ✅ Clean Code ✅ Object-Oriented Design

Slide 4

Slide 4 text

Logging

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

betterstack.com/logs 6

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

HttpAppender Our very own creation Just for fun

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

logs.betterstack.com 15

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

Encoder

Slide 18

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

SLF4J Logback | Logging 20

Slide 21

Slide 21 text

One Last Thing

Slide 22

Slide 22 text

What if …? 22 Box Name 1 Name 2 Cat Car What is a Flowchart diagram? _

Slide 23

Slide 23 text

Chatbot 23

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

Open AI 2024 1. Go to the OpenAI website a t https://pl a tform.open a i.com/ a nd click on the "Sign Up" button in the top-right corner of the p a ge. 2.Follow the prompts to cre a te a n a ccount a nd verify your em a il a ddress. 3.Once you're logged in, click on your user photo a t the lower left corner of the p a ge a nd Then on the "API Keys" option in the d a shbo a rd menu. 4.In Project API Keys, Click on the ”Cre a te New Secret Key" button. 5.Enter a n a me for your API key a nd select the API permissions you w a nt to gr a nt to the key. 6.Click the "Cre a te" button to gener a te your new key. 27

Slide 28

Slide 28 text

Note • St a rting from M a rch 25, 2024, OpenAI implemented a new billing method for the OpenAI API a ccounts. Inste a d of receiving a bill a t the end of e a ch month, users must pre-purch a se credits to use the API vi a the billing p a ge. • J a nu a ry 2024 (GTP-35): • Input Tokens: $0.0015 per 1,000 tokens • Output Tokens: $0.002 per 1,000 tokens • Tokens: Tokens c a n be a s short a s one ch a r a cter or a s long a s one word Typic a lly, 1,000 tokens is a bout 750 words. 28

Slide 29

Slide 29 text

Chatbot 29

Slide 30

Slide 30 text

( 30

Slide 31

Slide 31 text

Properties File • Cre a te a new f ile in your resource's directory (usu a lly src/m a in/resources in a M a ven project) a nd n a me it for ex a mple con f ig.properties (or a ny n a me you prefer). • Add the properties you need in this f ile. 31

Slide 32

Slide 32 text

Properties 32

Slide 33

Slide 33 text

Properties This f ile should not be committed to your version control system if it cont a ins sensitive inform a tion like API keys. Advice: • Cre a te a copy of your con f ig.properties f ile a nd n a me it con f ig.s a mple.properties. Repl a ce the sensitive d a t a like the API key with pl a ceholder v a lues. • Add con f ig.properties to your .gitignore f ile. This will prevent the a ctu a l properties f ile from being tr a cked by Git. • Commit the con f ig.s a mple.properties f ile to your repository. This will provide a templ a te for other developers to know wh a t keys/v a lues a re expected in the a ctu a l con f ig.properties f ile. 33

Slide 34

Slide 34 text

) 34

Slide 35

Slide 35 text

35 https://github.com/CSC3100/Cloud-Services

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

JSON Response {"id":"cmpl78QWL0xfnaEHWzTuCJZhpBK3OshrR", "object":"text_completion", "created":1682242925, "model":"gpt-3.5-turbo-instruct", "choices":[{ "text":"ANSWER TEXT HERE", "index":0, "logprobs":null, "finish_reason":"stop" }], "usage":{ "prompt_tokens":1, "completion_tokens":76, "total_tokens":77 } } 42

Slide 43

Slide 43 text

Questions 43

Slide 44

Slide 44 text

Lab

Slide 45

Slide 45 text

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

Slide 46

Slide 46 text

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

Slide 47

Slide 47 text

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

Slide 48

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

Slide 49

Slide 49 text

SLF4J Logback | Logging 49

Slide 50

Slide 50 text

50 Save the Log on a File with JSON format

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.