SlideShare uma empresa Scribd logo
1 de 30
©2010 Improving Enterprises, Inc.
Logging For Fun and Profit
Jane Prusakova
Jane.Prusakova@ImprovingEnter
prises.com
http://softwareandotherthings.blog
spot.com
Improving Enterprises
AA.com
2013
©2010 Improving Enterprises, Inc.
Why
How-to
Using the results
©2010 Improving Enterprises, Inc.
Why logging?
Enquiring minds want to know!
Avoid programming-by-coincidence
Trace what the users do
See effects of
Integration
Multithreading
High load
©2010 Improving Enterprises, Inc.
When to use logging?
Greenfield development
Brownfield development
what came before
the effect of changes
Maintenance and troubleshooting
trace bugs
Bonus
Evolve apps based on users behavior
©2010 Improving Enterprises, Inc.
Logging [vs Debugging]
Set up once, always ready to use
Minimum disruption to the flow
Works locally and in the cloud
Faster data collection
Collected data is persisted
©2010 Improving Enterprises, Inc.
How-to
Using the results
©2010 Improving Enterprises, Inc.
Yes, I want to setup logging!
Pick a framework
Proper configuration
Consider ways to parse logs
Logging will change with the application
©2010 Improving Enterprises, Inc.
Log4J SLF4J
Apache MIT license
Logging framework Logging facade
Configuration, log levels and categories,
rotate log files, thread-safe logging.
Support: online documentation, tutorials,
online forums.
©2010 Improving Enterprises, Inc.
Where to write logs?
Console
File system
DB
Queue mechanisms
Combination
©2010 Improving Enterprises, Inc.
Database Files
Easy to parse,
hard to evolve
Very hard to parse,
easy to change
Uses DB
connections
Requires FS
access
Can cause app
crash, loss of logs,
slow down app
Can fill up space
©2010 Improving Enterprises, Inc.
Configuring Log4J
Java properties-style
XML
Programmatically
Hard-coded
Takes preference
©2010 Improving Enterprises, Inc.
Log Message
What to log with the message
Importance level
When
Where in the code
Data being processed
Thread information
©2010 Improving Enterprises, Inc.
Example layout
log4j.appender.stdout.layout.ConversionPattern=
%d %5p [%t] (%F:%L) - %m%n
- Date
- Log Level
- Thread name
- File and line (slow to retrieve)
©2010 Improving Enterprises, Inc.
Enough and but not too much
Logging should support in code
correctness
readability
performance
Consider making logs easier to use
©2010 Improving Enterprises, Inc.
Best Practices
Relate each message to generating point
Code
Data
Format messages for readability
Use .ToString on objects
©2010 Improving Enterprises, Inc.
More Best Practices
Input and output
Errors and exceptions
Transitions
Integration points
Thread rendezvous
©2010 Improving Enterprises, Inc.
Log input and output
public int calculateCost(String user, Flight flight)
{
log.debug(“calculateCost: user “ + user + “:
“ + flight);
int cost = … ;
… // cost calculation
log.debug((“calculateCost: cost for “ + user
+ “ on “ + flight + “: “ + cost);
return cost;
}
©2010 Improving Enterprises, Inc.
Log errors and exceptions
// do dangerous work
result = DoDangerousWork(user, flight);
}
catch (Exception e)
{
log.error(“methodName: exception in
DoDangerousWork for user “ + user + “ on “ +
flight, e);
// recover or re-throw
}
©2010 Improving Enterprises, Inc.
More
Log destination, parameters, outcomes
DB calls
SOAP calls
Wait time
Thread joins
Available memory
Memory-intensive operations
Intermediate calculation results
For complicated calculations
©2010 Improving Enterprises, Inc.
Practices to avoid
Little information
… // step 1
Logger.info(“did something”);
… // ste 2
Logger.info(“did more work”);
foreach (…) {
… // useful work
Logger.info(“working hard”);
}
©2010 Improving Enterprises, Inc.
Watch for logging-caused bugs
Side effects
Logger.info(count++ “: did something”);
Errors and exceptions
Logger.info(m.GetValue());
©2010 Improving Enterprises, Inc.
More practices to avoid
DRY principle applies
©2010 Improving Enterprises, Inc.
Using the results
©2010 Improving Enterprises, Inc.
You’ve got logs!
Rotate logs: by size, by time
Retention policy
2-level storage
Provide access - read only!
Transfer and analysis
Warning: large datasets
©2010 Improving Enterprises, Inc.
Security and performance
Moving and processing
can impact performance
Absolutely no sensitive
data
©2010 Improving Enterprises, Inc.
Learning from the logs
Never rely on eye-balling
WYS is not WYG
Aggregate data
Distinguish common and
rare
©2010 Improving Enterprises, Inc.
Tools
Process datasets:
Line by line
grep, Perl, awk, cut, tail, head
Load entire file to eyeball
vi, notepad++
Better way to eyeball
more, less
©2010 Improving Enterprises, Inc.
Learning from the logs
> grep userName MyApplication.log
grep methodName MyApplication.log
grep threadName MyApplication.log
tail -2000 VeryImportant.log | grep Exception
grep FATAL MyApplication.log
©2010 Improving Enterprises, Inc.
Querying logs using Awk
GNU Awk www.gnu.org/software/gawk
create histograms
Wait times
Number of calls
Exceptions per time period or per user
Compare and relate events
Exception stacks traces
Outcomes by caller or thread
©2010 Improving Enterprises, Inc.
Logging For Fun and Profit
Jane Prusakova
Jane.Prusakova@ImprovingEnter
prises.com
http://softwareandotherthings.blog
spot.com
Improving Enterprises
AA.com
2013

Mais conteúdo relacionado

Semelhante a Application logging for fun and profit

Extending uBuild and uDeploy with Plugins
Extending uBuild and uDeploy with PluginsExtending uBuild and uDeploy with Plugins
Extending uBuild and uDeploy with PluginsIBM UrbanCode Products
 
HTML5 Web Workers-unleashed
HTML5 Web Workers-unleashedHTML5 Web Workers-unleashed
HTML5 Web Workers-unleashedPeter Lubbers
 
How To Build a Multi-Field Search Page For Your XPages Application
How To Build a Multi-Field Search Page For Your XPages ApplicationHow To Build a Multi-Field Search Page For Your XPages Application
How To Build a Multi-Field Search Page For Your XPages ApplicationMichael McGarel
 
Using GPOs to Configure and Tune Desktops
Using GPOs to Configure and Tune DesktopsUsing GPOs to Configure and Tune Desktops
Using GPOs to Configure and Tune DesktopsUnidesk Corporation
 
Building Creative Product Extensions with Experience Manager
Building Creative Product Extensions with Experience ManagerBuilding Creative Product Extensions with Experience Manager
Building Creative Product Extensions with Experience Managerconnectwebex
 
Maximize the power of OSGi in AEM
Maximize the power of OSGi in AEM Maximize the power of OSGi in AEM
Maximize the power of OSGi in AEM ICF CIRCUIT
 
Building Creative Product Extensions with Experience Manager
Building Creative Product Extensions with Experience ManagerBuilding Creative Product Extensions with Experience Manager
Building Creative Product Extensions with Experience ManagerJustin Edelson
 
embedding web browser in your app
embedding web browser in your appembedding web browser in your app
embedding web browser in your appSamsung
 
A gently introduction to AngularJS
A gently introduction to AngularJSA gently introduction to AngularJS
A gently introduction to AngularJSGregor Woiwode
 
STSADM Automating SharePoint Administration - Tech Ed South East Asia 2008 wi...
STSADM Automating SharePoint Administration - Tech Ed South East Asia 2008 wi...STSADM Automating SharePoint Administration - Tech Ed South East Asia 2008 wi...
STSADM Automating SharePoint Administration - Tech Ed South East Asia 2008 wi...Joel Oleson
 
Best Practices & Lessons Learned from the field on EMC Documentum xCP 2.0
Best Practices & Lessons Learned from the field on EMC Documentum xCP 2.0Best Practices & Lessons Learned from the field on EMC Documentum xCP 2.0
Best Practices & Lessons Learned from the field on EMC Documentum xCP 2.0Haytham Ghandour
 
The Steady State Reduce Spikiness from GPU Utilization with Apache MXNet (inc...
The Steady State Reduce Spikiness from GPU Utilization with Apache MXNet (inc...The Steady State Reduce Spikiness from GPU Utilization with Apache MXNet (inc...
The Steady State Reduce Spikiness from GPU Utilization with Apache MXNet (inc...Amazon Web Services
 
Iphone client-server app with Rails backend (v3)
Iphone client-server app with Rails backend (v3)Iphone client-server app with Rails backend (v3)
Iphone client-server app with Rails backend (v3)Sujee Maniyam
 
Moving applications to the cloud
Moving applications to the cloudMoving applications to the cloud
Moving applications to the cloudSergejus Barinovas
 
HFM API Deep Dive – Making a Better Financial Management Client
HFM API Deep Dive – Making a Better Financial Management ClientHFM API Deep Dive – Making a Better Financial Management Client
HFM API Deep Dive – Making a Better Financial Management ClientCharles Beyer
 
Google cloud platform
Google cloud platformGoogle cloud platform
Google cloud platformrajdeep
 

Semelhante a Application logging for fun and profit (20)

Extending uBuild and uDeploy with Plugins
Extending uBuild and uDeploy with PluginsExtending uBuild and uDeploy with Plugins
Extending uBuild and uDeploy with Plugins
 
HTML5 Web Workers-unleashed
HTML5 Web Workers-unleashedHTML5 Web Workers-unleashed
HTML5 Web Workers-unleashed
 
Good code
Good codeGood code
Good code
 
How To Build a Multi-Field Search Page For Your XPages Application
How To Build a Multi-Field Search Page For Your XPages ApplicationHow To Build a Multi-Field Search Page For Your XPages Application
How To Build a Multi-Field Search Page For Your XPages Application
 
Using GPOs to Configure and Tune Desktops
Using GPOs to Configure and Tune DesktopsUsing GPOs to Configure and Tune Desktops
Using GPOs to Configure and Tune Desktops
 
What's new in designer
What's new in designerWhat's new in designer
What's new in designer
 
Building Creative Product Extensions with Experience Manager
Building Creative Product Extensions with Experience ManagerBuilding Creative Product Extensions with Experience Manager
Building Creative Product Extensions with Experience Manager
 
Maximize the power of OSGi in AEM
Maximize the power of OSGi in AEM Maximize the power of OSGi in AEM
Maximize the power of OSGi in AEM
 
Building Creative Product Extensions with Experience Manager
Building Creative Product Extensions with Experience ManagerBuilding Creative Product Extensions with Experience Manager
Building Creative Product Extensions with Experience Manager
 
embedding web browser in your app
embedding web browser in your appembedding web browser in your app
embedding web browser in your app
 
A gently introduction to AngularJS
A gently introduction to AngularJSA gently introduction to AngularJS
A gently introduction to AngularJS
 
STSADM Automating SharePoint Administration - Tech Ed South East Asia 2008 wi...
STSADM Automating SharePoint Administration - Tech Ed South East Asia 2008 wi...STSADM Automating SharePoint Administration - Tech Ed South East Asia 2008 wi...
STSADM Automating SharePoint Administration - Tech Ed South East Asia 2008 wi...
 
Kscope presentation 2013
Kscope presentation 2013Kscope presentation 2013
Kscope presentation 2013
 
Best Practices & Lessons Learned from the field on EMC Documentum xCP 2.0
Best Practices & Lessons Learned from the field on EMC Documentum xCP 2.0Best Practices & Lessons Learned from the field on EMC Documentum xCP 2.0
Best Practices & Lessons Learned from the field on EMC Documentum xCP 2.0
 
Industrial IoT bootcamp
Industrial IoT bootcampIndustrial IoT bootcamp
Industrial IoT bootcamp
 
The Steady State Reduce Spikiness from GPU Utilization with Apache MXNet (inc...
The Steady State Reduce Spikiness from GPU Utilization with Apache MXNet (inc...The Steady State Reduce Spikiness from GPU Utilization with Apache MXNet (inc...
The Steady State Reduce Spikiness from GPU Utilization with Apache MXNet (inc...
 
Iphone client-server app with Rails backend (v3)
Iphone client-server app with Rails backend (v3)Iphone client-server app with Rails backend (v3)
Iphone client-server app with Rails backend (v3)
 
Moving applications to the cloud
Moving applications to the cloudMoving applications to the cloud
Moving applications to the cloud
 
HFM API Deep Dive – Making a Better Financial Management Client
HFM API Deep Dive – Making a Better Financial Management ClientHFM API Deep Dive – Making a Better Financial Management Client
HFM API Deep Dive – Making a Better Financial Management Client
 
Google cloud platform
Google cloud platformGoogle cloud platform
Google cloud platform
 

Mais de Jane Prusakova

Software architecture houstontechfest2020
Software architecture houstontechfest2020Software architecture houstontechfest2020
Software architecture houstontechfest2020Jane Prusakova
 
Estimating software development
Estimating software developmentEstimating software development
Estimating software developmentJane Prusakova
 
Thoughts on building software architecture
Thoughts on building software architectureThoughts on building software architecture
Thoughts on building software architectureJane Prusakova
 
Improving IT Performance
Improving IT PerformanceImproving IT Performance
Improving IT PerformanceJane Prusakova
 
Agile Software Development
Agile Software DevelopmentAgile Software Development
Agile Software DevelopmentJane Prusakova
 
Questions of Ethics in Software Development
Questions of Ethics in Software DevelopmentQuestions of Ethics in Software Development
Questions of Ethics in Software DevelopmentJane Prusakova
 
Managing remote teams.
Managing remote teams.Managing remote teams.
Managing remote teams.Jane Prusakova
 
Gender-neutral Recruiting
Gender-neutral RecruitingGender-neutral Recruiting
Gender-neutral RecruitingJane Prusakova
 
Privacy In The Digital Age
Privacy In The Digital AgePrivacy In The Digital Age
Privacy In The Digital AgeJane Prusakova
 
Interview: a Learning Conversation
Interview: a Learning ConversationInterview: a Learning Conversation
Interview: a Learning ConversationJane Prusakova
 
Lets talk about good code
Lets talk about good codeLets talk about good code
Lets talk about good codeJane Prusakova
 
Motivating Knowledge Workers
Motivating Knowledge WorkersMotivating Knowledge Workers
Motivating Knowledge WorkersJane Prusakova
 
Pragmatic Agile: distributed teams
Pragmatic Agile: distributed teamsPragmatic Agile: distributed teams
Pragmatic Agile: distributed teamsJane Prusakova
 
A case for remote teams
A case for remote teamsA case for remote teams
A case for remote teamsJane Prusakova
 

Mais de Jane Prusakova (20)

Software architecture houstontechfest2020
Software architecture houstontechfest2020Software architecture houstontechfest2020
Software architecture houstontechfest2020
 
Estimating software development
Estimating software developmentEstimating software development
Estimating software development
 
Better remote teams
Better remote teamsBetter remote teams
Better remote teams
 
Thoughts on building software architecture
Thoughts on building software architectureThoughts on building software architecture
Thoughts on building software architecture
 
Improving IT Performance
Improving IT PerformanceImproving IT Performance
Improving IT Performance
 
Agile Software Development
Agile Software DevelopmentAgile Software Development
Agile Software Development
 
Questions of Ethics in Software Development
Questions of Ethics in Software DevelopmentQuestions of Ethics in Software Development
Questions of Ethics in Software Development
 
Just startcoding
Just startcodingJust startcoding
Just startcoding
 
Just start coding
Just start codingJust start coding
Just start coding
 
Managing remote teams.
Managing remote teams.Managing remote teams.
Managing remote teams.
 
Gender-neutral Recruiting
Gender-neutral RecruitingGender-neutral Recruiting
Gender-neutral Recruiting
 
Privacy In The Digital Age
Privacy In The Digital AgePrivacy In The Digital Age
Privacy In The Digital Age
 
Interview: a Learning Conversation
Interview: a Learning ConversationInterview: a Learning Conversation
Interview: a Learning Conversation
 
Effective Code Review
Effective Code ReviewEffective Code Review
Effective Code Review
 
Effective Code Review
Effective Code ReviewEffective Code Review
Effective Code Review
 
Lets talk about good code
Lets talk about good codeLets talk about good code
Lets talk about good code
 
Motivating Knowledge Workers
Motivating Knowledge WorkersMotivating Knowledge Workers
Motivating Knowledge Workers
 
What is good code?
What is good code?What is good code?
What is good code?
 
Pragmatic Agile: distributed teams
Pragmatic Agile: distributed teamsPragmatic Agile: distributed teams
Pragmatic Agile: distributed teams
 
A case for remote teams
A case for remote teamsA case for remote teams
A case for remote teams
 

Último

Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 

Último (20)

Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Application logging for fun and profit

  • 1. ©2010 Improving Enterprises, Inc. Logging For Fun and Profit Jane Prusakova Jane.Prusakova@ImprovingEnter prises.com http://softwareandotherthings.blog spot.com Improving Enterprises AA.com 2013
  • 2. ©2010 Improving Enterprises, Inc. Why How-to Using the results
  • 3. ©2010 Improving Enterprises, Inc. Why logging? Enquiring minds want to know! Avoid programming-by-coincidence Trace what the users do See effects of Integration Multithreading High load
  • 4. ©2010 Improving Enterprises, Inc. When to use logging? Greenfield development Brownfield development what came before the effect of changes Maintenance and troubleshooting trace bugs Bonus Evolve apps based on users behavior
  • 5. ©2010 Improving Enterprises, Inc. Logging [vs Debugging] Set up once, always ready to use Minimum disruption to the flow Works locally and in the cloud Faster data collection Collected data is persisted
  • 6. ©2010 Improving Enterprises, Inc. How-to Using the results
  • 7. ©2010 Improving Enterprises, Inc. Yes, I want to setup logging! Pick a framework Proper configuration Consider ways to parse logs Logging will change with the application
  • 8. ©2010 Improving Enterprises, Inc. Log4J SLF4J Apache MIT license Logging framework Logging facade Configuration, log levels and categories, rotate log files, thread-safe logging. Support: online documentation, tutorials, online forums.
  • 9. ©2010 Improving Enterprises, Inc. Where to write logs? Console File system DB Queue mechanisms Combination
  • 10. ©2010 Improving Enterprises, Inc. Database Files Easy to parse, hard to evolve Very hard to parse, easy to change Uses DB connections Requires FS access Can cause app crash, loss of logs, slow down app Can fill up space
  • 11. ©2010 Improving Enterprises, Inc. Configuring Log4J Java properties-style XML Programmatically Hard-coded Takes preference
  • 12. ©2010 Improving Enterprises, Inc. Log Message What to log with the message Importance level When Where in the code Data being processed Thread information
  • 13. ©2010 Improving Enterprises, Inc. Example layout log4j.appender.stdout.layout.ConversionPattern= %d %5p [%t] (%F:%L) - %m%n - Date - Log Level - Thread name - File and line (slow to retrieve)
  • 14. ©2010 Improving Enterprises, Inc. Enough and but not too much Logging should support in code correctness readability performance Consider making logs easier to use
  • 15. ©2010 Improving Enterprises, Inc. Best Practices Relate each message to generating point Code Data Format messages for readability Use .ToString on objects
  • 16. ©2010 Improving Enterprises, Inc. More Best Practices Input and output Errors and exceptions Transitions Integration points Thread rendezvous
  • 17. ©2010 Improving Enterprises, Inc. Log input and output public int calculateCost(String user, Flight flight) { log.debug(“calculateCost: user “ + user + “: “ + flight); int cost = … ; … // cost calculation log.debug((“calculateCost: cost for “ + user + “ on “ + flight + “: “ + cost); return cost; }
  • 18. ©2010 Improving Enterprises, Inc. Log errors and exceptions // do dangerous work result = DoDangerousWork(user, flight); } catch (Exception e) { log.error(“methodName: exception in DoDangerousWork for user “ + user + “ on “ + flight, e); // recover or re-throw }
  • 19. ©2010 Improving Enterprises, Inc. More Log destination, parameters, outcomes DB calls SOAP calls Wait time Thread joins Available memory Memory-intensive operations Intermediate calculation results For complicated calculations
  • 20. ©2010 Improving Enterprises, Inc. Practices to avoid Little information … // step 1 Logger.info(“did something”); … // ste 2 Logger.info(“did more work”); foreach (…) { … // useful work Logger.info(“working hard”); }
  • 21. ©2010 Improving Enterprises, Inc. Watch for logging-caused bugs Side effects Logger.info(count++ “: did something”); Errors and exceptions Logger.info(m.GetValue());
  • 22. ©2010 Improving Enterprises, Inc. More practices to avoid DRY principle applies
  • 23. ©2010 Improving Enterprises, Inc. Using the results
  • 24. ©2010 Improving Enterprises, Inc. You’ve got logs! Rotate logs: by size, by time Retention policy 2-level storage Provide access - read only! Transfer and analysis Warning: large datasets
  • 25. ©2010 Improving Enterprises, Inc. Security and performance Moving and processing can impact performance Absolutely no sensitive data
  • 26. ©2010 Improving Enterprises, Inc. Learning from the logs Never rely on eye-balling WYS is not WYG Aggregate data Distinguish common and rare
  • 27. ©2010 Improving Enterprises, Inc. Tools Process datasets: Line by line grep, Perl, awk, cut, tail, head Load entire file to eyeball vi, notepad++ Better way to eyeball more, less
  • 28. ©2010 Improving Enterprises, Inc. Learning from the logs > grep userName MyApplication.log grep methodName MyApplication.log grep threadName MyApplication.log tail -2000 VeryImportant.log | grep Exception grep FATAL MyApplication.log
  • 29. ©2010 Improving Enterprises, Inc. Querying logs using Awk GNU Awk www.gnu.org/software/gawk create histograms Wait times Number of calls Exceptions per time period or per user Compare and relate events Exception stacks traces Outcomes by caller or thread
  • 30. ©2010 Improving Enterprises, Inc. Logging For Fun and Profit Jane Prusakova Jane.Prusakova@ImprovingEnter prises.com http://softwareandotherthings.blog spot.com Improving Enterprises AA.com 2013

Notas do Editor

  1. Shilpa: Without proper planning and clear strategy, the log messages produced by the system may not be useful for problem resolution.Effective logging is a balance between logging enough data to debug problems, while not dumping so much it confuses the issue.
  2. Shilpa: Without proper planning and clear strategy, the log messages produced by the system may not be useful for problem resolution.Effective logging is a balance between logging enough data to debug problems, while not dumping so much it confuses the issue.
  3. Log4J is old, excellent, widely used framework.SLF4J is written by the same author as Log4J. Both licenses permit for-profit usage.
  4. Both Log4net and Nlog are open source, free libraries. Well-used and well-loved, mature technologies, that are known to work very well. No option to buy corporate support, but there is plenty of free support from the user community available online.
  5. Console – for debugging purposes onlyWhile I prefer to log to a file: More flexibility to change what is being loggedLogging doesn’t compete with the application for DB connectionsDB access is broken more often than file accessWhy you may choose to log to the DB: Easier to parse logsIt is possible to use Aspects to separate logging concerns from the application logic - for logs that are stable. If you use logging to trace problems as the application is being developed and maintained – putting logs with the code is simpler and helps to shorted the development cycle.
  6. While I prefer to log to a file: More flexibility to change what is being loggedLogging doesn’t compete with the application for DB connectionsDB access is broken more often than file accessWhy you may choose to log to the DB: Easier to parse logsIt is possible to use Aspects to separate logging concerns from the application logic - for logs that are stable. If you use logging to trace problems as the application is being developed and maintained – putting logs with the code is simpler and helps to shorted the development cycle.
  7. Java properties is older, XML format can be more convenient since lots of other configuration is also done in XML.Whichever configuration file is found first on the file path is loaded and used. Configuring logging in code is generally a bad idea – any changes will require a re-compile and re-install.
  8. Where in the code can be specified approximately, by outputting class, or in details, with file name, full class path, line number of the log request. Depending on the situation, it maybe helpful to have: Method caller informationthread diagnostic context-additional information on the state of the calling codeEach logging event should generate 1 line in the log file – makes for easier log processing.
  9. While I prefer to log to a file: More flexibility to change what is being loggedLogging doesn’t compete with the application for DB connectionsDB access is broken more often than file accessWhy you may choose to log to the DB: Easier to parse logsIt is possible to use Aspects to separate logging concerns from the application logic - for logs that are stable. If you use logging to trace problems as the application is being developed and maintained – putting logs with the code is simpler and helps to shorted the development cycle.
  10. Go back to examples
  11. Go back to examples
  12. Go back to examples
  13. Go back to examples
  14. Unless step 1 or step 2 throw, we already know both will happen – no need to log the second.When putting loggin inside a loop, it’s helpful to record loop counter and the item being processed.
  15. Make sure logging operation itself will not add errors.Wrapping logging code in try-catch adds lines, making code less readable, and overhead. So, test!
  16. It is important that logs are dense with information. If logging an object with no ToString method, it’s full type name will be printed – bad.Frameworks provide a way to post file and line from where logging is done – no need to do it in text. It’s fine to reduce logging as the code becomes stable and appears to have no more bugs.
  17. Shilpa: Without proper planning and clear strategy, the log messages produced by the system may not be useful for problem resolution.Effective logging is a balance between logging enough data to debug problems, while not dumping so much it confuses the issue.
  18. How to handle large log files,e.g Roll the files.... (zip them up after certain days etc....)
  19. Programs that experience issues tend to log more, causing higher log volume, more stress on the disk, and more frequent log rotation. Which could make the situation worse. Watching log’s rate of growth can provide information on the health of the application.
  20. A rare bug is harder to trace – and usually presents less of a problem to the business. When arbitraging future work, use logs to learn what users want.
  21. Cygwin-provided Unix utilities work great on Windows
  22. Target your research: Trace by user, by what happens in a particular piece of code, or what is logged at a particular level.
  23. A rare bug is harder to trace – and usually presents less of a problem to the business. When arbitraging future work, use logs to learn what users want.