SlideShare a Scribd company logo
©2010 Improving Enterprises, Inc.
Logging For Fun and Profit
Jane Prusakova
Jane.Prusakova@ImprovingEnterprises.com
http://softwareandotherthings.blogspot.com
Improving Enterprises
Houston JUG
2014
©2010 Improving Enterprises, Inc.
Jane Prusakova
Hard-core developer
Data science geek
Dancer and photographer
©2010 Improving Enterprises, Inc.
Why
How-to
Using the results
So lets talk about logging…
©2010 Improving Enterprises, Inc.
Peek into the soul
Real setup
Real data
Real users
Real work
Dev environment
Happy path
Minimum load
Limited data
©2010 Improving Enterprises, Inc.
Inside the cloud
No programming-by-coincidence
Replaces debugging
Works on server
©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.
Logging helps with…
Integration
Multithreading
High load
©2010 Improving Enterprises, Inc.
What else?
Trace what the users do
Features
Sequences
Data flow
©2010 Improving Enterprises, Inc.
When to use logging?
New systems
New features
Bug fixing
©2010 Improving Enterprises, Inc.
Are logs forever?
Permanent
Errors
Extraordinary situations
©2010 Improving Enterprises, Inc.
Some are seasonal
Very temporary
Debugging info
Trace bug fixes
©2010 Improving Enterprises, Inc.
Others last awhile
Medium term
Data flow
Resource utilization
Optimization points
©2010 Improving Enterprises, Inc.
How-to
Using the results
©2010 Improving Enterprises, Inc.
Yes, I want to setup logging!
Pick a framework
Configure logging
Storage and access
Getting value from logs
©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.
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.
Where to write logs?
Console
File system
DB
Queue mechanisms
Combination
©2010 Improving Enterprises, Inc.
Logging configuration
Java properties-style
XML
Programmatically
Hard-coded
Takes preference
©2010 Improving Enterprises, Inc.
Log Message
What to log with the message
Importance level
Timestamp
Where in the code
Data being processed
System state info
©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.
Good log messages
Support code
Correctness
Readability
Performance
©2010 Improving Enterprises, Inc.
Better log messages
Relate to generating point
Code
Data
©2010 Improving Enterprises, Inc.
Best log messages
Are formatted for
Readability
Aggregation
©2010 Improving Enterprises, Inc.
Logging objects
.toString()
org.apache.commons.lang.builder.ToStringBuilder
log.info(myDataObject);
©2010 Improving Enterprises, Inc.
What to log
Input and output
Errors and exceptions
Computation results
Integration points
Thread rendezvous
©2010 Improving Enterprises, Inc.
Input and output
public int calculateCost(String user, Flight flight)
{
log.debug(“calculateCost: “ + user + “: “ +
flight);
int cost = … ;
… // cost calculation
log.debug((“calculateCost: cost for “ + user
+ “: “ + flight + “ = “ + cost);
return cost;
}
©2010 Improving Enterprises, Inc.
Errors and exceptions
// do dangerous work
result = DoDangerousWork(user, flight);
}
catch (Exception e)
{
log.error(“methodName: exception in
DoDangerousWork for “ + user + “: “ + 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.
Avoid
Little information
… // step 1
logger.info(“did something - XXXX”);
… // step 2
logger.info(“did more work - YYYY”);
foreach (…) {
… // useful work
logger.info(“working hard”);
}
©2010 Improving Enterprises, Inc.
Avoid
Code cluttering
if (logger.isDebugEnabled()) {
logger.debug(“Show Views");
logger.debug("Address:n" +
view.getAddress());
logger.debug("Email:n" +
view.getEmail());
}
©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.
DRY principle applies
©2010 Improving Enterprises, Inc.
Growing, growing…
Naming conventions
Rotation
by size
by time
©2010 Improving Enterprises, Inc.
You’ve got logs!
Real-time access
Deal with space limitations
Warning: large datasets
©2010 Improving Enterprises, Inc.
Security
Absolutely
No Sensitive Data
©2010 Improving Enterprises, Inc.
Using the results
©2010 Improving Enterprises, Inc.
Learning from the logs
Never rely on eye-balling
WYS is not WYG
Distinguish common and
rare
©2010 Improving Enterprises, Inc.
Code and logs
©2010 Improving Enterprises, Inc.
Process log
Line by line
No need to load entire file
Aggregate events
Relate to time
©2010 Improving Enterprises, Inc.
Tools
Utilities
grep
sort
uniq
Scripting
Perl
Awk
sed
©2010 Improving Enterprises, Inc.
Learning from the logs
> grep userName myApplication-MMDDYYYY.log
> grep methodName myApplication-MMDDYYYY.log
> grep FATAL myApplication-MMDDYYYY.log
> tail -2000 myApplication-MMDDYYYY.log | grep Exception
©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.
AWK demo
Logs for the demo generously
provided by
http://42graphy.org/
©2010 Improving Enterprises, Inc.
Jane.Prusakova at ImprovingEnterprises.com
SoftwareAndOtherThings.blogspot.com
@jprusakova
Jane Prusakova
http://www.slideshare.net/jprusakova
©2010 Improving Enterprises, Inc.
Logging For Fun and Profit
Jane Prusakova
Jane.Prusakova@ImprovingEnterprises.com
http://softwareandotherthings.blogspot.com
Improving Enterprises
Houston JUG
2014

More Related Content

PPTX
Back-2-Basics: .NET Coding Standards For The Real World
PDF
Web application finger printing - whitepaper
PPTX
PPTX
Good code
PPTX
The power of nudge. Building great teams.
PPTX
Application logging for fun and profit
PPTX
Application Logging for fun and profit. Houston TechFest 2012
PDF
Developer Fundamentals - Logging
Back-2-Basics: .NET Coding Standards For The Real World
Web application finger printing - whitepaper
Good code
The power of nudge. Building great teams.
Application logging for fun and profit
Application Logging for fun and profit. Houston TechFest 2012
Developer Fundamentals - Logging

Similar to Application Logging for large systems (20)

PPT
19-reliabilitytesting.ppt
PDF
Mining Development Knowledge to Understand and Support Software Logging Pract...
PDF
LOGGING FOR FUN, AND PROFIT
PDF
Un-broken Logging - Operability.io 2015 - Matthew Skelton
PDF
Un-broken logging - the foundation of software operability - Operability.io -...
PPT
Application Logging Good Bad Ugly ... Beautiful?
PDF
Un-broken Logging - TechnologyUG - Leeds - Matthew Skelton
PDF
Opslogger: Operations code (should be) production quality too!
PDF
Helpful logging with Java
PDF
PDF
Are logs a software engineer’s best friend? Yes -- follow these best practices
PPTX
Logging best practice in mule using logger component
PDF
Day 2 05 - steve feldman - logging matters
PDF
How i learned to stop worrying and love the logs
PDF
Conditional Logging Considered Harmful - Sean Reilly
PPTX
MojoPortal And Log4net
DOCX
JAVA LOGGING for JAVA APPLICATION PERFORMANCE
PDF
10 Tips to improve your application logs
PDF
Let's reconsider about collecting logs. Plus, visiting elastic@Moutain View!
PDF
Sustainable Logging – SplunkLive! 2014
19-reliabilitytesting.ppt
Mining Development Knowledge to Understand and Support Software Logging Pract...
LOGGING FOR FUN, AND PROFIT
Un-broken Logging - Operability.io 2015 - Matthew Skelton
Un-broken logging - the foundation of software operability - Operability.io -...
Application Logging Good Bad Ugly ... Beautiful?
Un-broken Logging - TechnologyUG - Leeds - Matthew Skelton
Opslogger: Operations code (should be) production quality too!
Helpful logging with Java
Are logs a software engineer’s best friend? Yes -- follow these best practices
Logging best practice in mule using logger component
Day 2 05 - steve feldman - logging matters
How i learned to stop worrying and love the logs
Conditional Logging Considered Harmful - Sean Reilly
MojoPortal And Log4net
JAVA LOGGING for JAVA APPLICATION PERFORMANCE
10 Tips to improve your application logs
Let's reconsider about collecting logs. Plus, visiting elastic@Moutain View!
Sustainable Logging – SplunkLive! 2014
Ad

More from Jane Prusakova (20)

PPTX
Software architecture houstontechfest2020
PPTX
Estimating software development
PPTX
Better remote teams
PPTX
Thoughts on building software architecture
PPTX
Improving IT Performance
PPTX
Agile Software Development
PPTX
Questions of Ethics in Software Development
PPTX
Just startcoding
PPTX
Just start coding
PPTX
Managing remote teams.
PPTX
Gender-neutral Recruiting
PPTX
Privacy In The Digital Age
PPTX
Interview: a Learning Conversation
PPTX
Effective Code Review
PPTX
Effective Code Review
PPTX
Lets talk about good code
PPTX
Motivating Knowledge Workers
PPTX
What is good code?
PPTX
Pragmatic Agile: distributed teams
PPTX
A case for remote teams
Software architecture houstontechfest2020
Estimating software development
Better remote teams
Thoughts on building software architecture
Improving IT Performance
Agile Software Development
Questions of Ethics in Software Development
Just startcoding
Just start coding
Managing remote teams.
Gender-neutral Recruiting
Privacy In The Digital Age
Interview: a Learning Conversation
Effective Code Review
Effective Code Review
Lets talk about good code
Motivating Knowledge Workers
What is good code?
Pragmatic Agile: distributed teams
A case for remote teams
Ad

Recently uploaded (20)

PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Empathic Computing: Creating Shared Understanding
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPT
Teaching material agriculture food technology
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
KodekX | Application Modernization Development
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
cuic standard and advanced reporting.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Spectral efficient network and resource selection model in 5G networks
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
sap open course for s4hana steps from ECC to s4
Unlocking AI with Model Context Protocol (MCP)
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Empathic Computing: Creating Shared Understanding
Dropbox Q2 2025 Financial Results & Investor Presentation
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Teaching material agriculture food technology
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
KodekX | Application Modernization Development
Diabetes mellitus diagnosis method based random forest with bat algorithm
Advanced methodologies resolving dimensionality complications for autism neur...
cuic standard and advanced reporting.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Spectroscopy.pptx food analysis technology
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Spectral efficient network and resource selection model in 5G networks

Application Logging for large systems