SlideShare a Scribd company logo
Mining Development Knowledge to
Understand and Support Software
Logging Practices
Heng Li
Supervisor: Dr. Ahmed E. Hassan
Software Analysis & Intelligence Lab (SAIL)
Queen’s University, Canada
Developers insert logging code that
produces log messages at runtime
2
Log()
Logging
code
Log
messages
Software
system
Log.info(“Stopping server on ” + port);
2016-07-23 17:56:16 INFO Stopping server on 8032
Log messages record valuable runtime information
Diagnose
failures
Logging is critical for software maintenance
Detect
anomalies
Log messages are widely used in software
maintenance efforts
3
Understand
runtime
behaviors
Fu et al., Contextual analysis of program logs
for understanding system behaviors. MSR ‘13
Yuan et al., Sherlog: Error diagnosis by
connecting clues from run-time logs. ASPLOS ‘10
Xu et al., Detecting large-scale system
problems by mining console logs. SOSP ‘09
Developers have difficulties deciding on
appropriate logging code
4
“A lot of log
noise”
“Slowing
down perf
by 20%”
“Missing an
error log”
Developers spend a significant amount of efforts
maintaining their logging code
§ Logging practices in open source projects
[Yuan et al., 2012; Chen and Jiang, 2017]
§ Logging practices in industry
[Shang et al, 2014; Fu et al, 2014]
Prior
work
Development knowledge explains
the development of logging code
5
− LOG.info(msg);
+ LOG.warn(msg);
To help users
identify a problem
LOG.warn(msg);
What How Why
Change historySource code Issue reports
Thesis statement
Development knowledge can help us understand
current logging practices and develop useful tools
to support such logging practices
6
Change historySource code Issue reports
Development knowledge
Mining development knowledge to
understand and support logging practices
7
Developers’
logging concerns?
[TSE under review]
Where to log?
When to update
log? How to log?
[EMSE 2018]
[EMSE 2017] [EMSE 2017]
Error
Warn
Info
Mining development knowledge to
understand and support logging practices
8
Developers’
logging concerns?
[TSE under review]
Where to log?
When to update
log? How to log?
[EMSE 2018]
[EMSE 2017] [EMSE 2017]
Error
Warn
Info
Developers communicate their logging
concerns in issue reports
9
Logging cost: performance overhead
Remove a logging statement
Developers communicate their logging
concerns in issue reports
10
Add a logging statement
Logging benefit:
exposing runtime problems
We study logging-related issues reports to
understand developer’s logging concerns
11
Logging
issue
reports
Logging
concerns
Automated
& manual
filtering
Qualitative
analysis
What are developers’ logging concerns?
12
Logging Benefits
§ Assisting in debugging
Logging Costs
§ Excessive log information
Research opportunities
Leverage Minimize
Frequency
§ Providing runtime perf
§ Exposing runtime problems
§ Bookkeeping
§ Showing execution progress
§ Exposing unnecessary details
§ Misleading end users
§ Performance overhead
§ Exposing sensitive info
Mining development knowledge to
understand and support logging practices
13
Developers’
logging concerns?
[TSE under review]
Where to log?
When to update
log? How to log?
[EMSE 2018]
[EMSE 2017] [EMSE 2017]
Error
Warn
Info
10 categories of
logging concerns
(e.g., misleading users)
Mining development knowledge to
understand and support logging practices
14
Developers’
logging concerns?
[TSE under review]
Where to log?
When to update
log? How to log?
[EMSE 2018]
[EMSE 2017] [EMSE 2017]
Error
Warn
Info
Some code topics are more likely to need
logging statements
15
Examples of JIRA issues that require developers to log
the topic of “connections”
[EMSE 2018]
Can code topics explain where to log?
Topic: “connection”
Logging statement
[EMSE 2018]
16
We extract the code topics and logging statements for
each code snippet (method level)
We use LDA to extract code topics
Logging statement
[EMSE 2018]
17
Tokenization
Topic model
(LDA)
queue, connection
Topic: “connection”
A small number of topics are much more
likely to be logged
Topic: “connection”
Logging statement
The most log-intensive topics usually capture
communication between machines (e.g., ”connection”) or
interactions between threads (e.g., “thread interruption”)
[EMSE 2018]
18
We combine both the structure and topic
info to explain where to log
Topic: “connection”
Logging statement
Structure info: lines of
code, complexity, control
flow statements, etc.
[EMSE 2018]
19
We combine both the structure and topic
info to explain where to log
Topic: “connection”
Logging statement
Structure info: lines of
code, complexity, control
flow statements, etc.
LASSO model
[EMSE 2018]
20
Code topics bring additional explanatory
power (up to 13% AUC improvement)
21
0.82
0.86
0.8
0.86
0.83
0.96
0.87
0.94
0.9 0.9 0.88
0.99
0.5
0.6
0.7
0.8
0.9
1
Structure info Structure & topic info
AUC
The performance (AUC) of our LASSO models
Random guess
[EMSE 2018]
Mining development knowledge to
understand and support logging practices
22
Developers’
logging concerns?
[TSE under review]
Where to log?
When to update
log? How to log?
[EMSE 2018]
[EMSE 2017] [EMSE 2017]
Error
Warn
Info
Logging varies
across code topics
Mining development knowledge to
understand and support logging practices
23
Developers’
logging concerns?
[TSE under review]
Where to log?
When to update
log? How to log?
[EMSE 2018]
[EMSE 2017] [EMSE 2017]
Error
Warn
Info
Developers have difficulties to make
appropriate log changes
24
Developers usually forget to change logging code when
they change their code; in many cases, logging code is
written as “after-thoughts” after a failure happens and
logs are needed [Yuan et al., 2012]
Commit n Commit n+1
Code
changes
Log
changes
Version k
Debugging
difficulties
Code change history
Maintenance
efforts
Learning from the code change history to
provide log change suggestions
25
[EMSE 2017]
Code Code Log Code Log
?
Commit 1 Commit 2 Commit n…
Code changes
without log
changes
Code changes
with log
changes
Do we need to
change logs?
Code change history
LOG?
Providing automated suggestions for log
changes when developers change the code
26
Random Forest
Classifier
Log change
suggestions
Three dimensions
25 metrics
Change
metrics
Historical
metrics
Product
metrics
[EMSE 2017]
Code
Our models can effectively suggest whether
a log change is needed
27
0.84
0.91
0.86 0.88
0.5
0.6
0.7
0.8
0.9
1
AUC
The performance (AUC) of our Random
Forest models
Random guess
[EMSE 2017]
LOG?
The source code and code changes are
important for explaining log changes
28
Log change
suggestions
Three dimensions
25 metrics
Change
metrics
Historical
metrics
Product
metrics
[EMSE 2017]
Code
Explain
Mining development knowledge to
understand and support logging practices
29
Developers’
logging concerns?
[TSE under review]
Where to log?
When to update
log? How to log?
[EMSE 2018]
[EMSE 2017] [EMSE 2017]
Error
Warn
Info
The source code &
code changes can
explain log changes
Mining development knowledge to
understand and support logging practices
30
Developers’
logging concerns?
[TSE under review]
Where to log?
When to update
log? How to log?
[EMSE 2018]
[EMSE 2017] [EMSE 2017]
Error
Warn
Info
Log levels are used to disable some verbose
log messages while enabling important ones
31
Trace
Debug
Info
Warn
Error
Fatal Less verbose levels
(higher levels)
More verbose
levels (lower levels)
Log.error(“message”)
Log level
Improper log levels can have many
negative impacts
32
“…tends to generate a lot
of log noise…”
“These warnings worry
users”
Developers spend much efforts adjusting log levels
[Yuan et al., 2012]
Learning from the code change history to
provide log level suggestions
33
[EMSE 2017]
Commit 1 Commit 2 Commit n…
Code change history
Log.warn(msg) Log.info(msg) Log. ? (msg)
Log.error(msg)
Which log level
to use?
Providing automated suggestions for log
levels when developers add logging code
34
Logging statement metrics
Containing block metrics
Containing file metrics
Code change metrics
Historical change metrics
Trace
Debug
Info
Warn
Error
Fatal
Ordinal
Regression
Model
[EMSE 2017]
Ordinal regression models can effectively
model log levels
35
0.76
0.78
0.81
0.75
0.5
0.6
0.7
0.8
0.9
The performance (AUC) of our Ordinal
Regression Models
AUC
Random guess
[EMSE 2017]
The content of a logging statements and the
containing block/file explain its log level
36
Logging statement metrics
Containing block metrics
Containing file metrics
Code change metrics
Historical change metrics
Trace
Debug
Info
Warn
Error
Fatal
[EMSE 2017]
Explain
Mining development knowledge to
understand and support logging practices
37
Developers’
logging concerns?
[TSE under review]
Where to log?
When to update
log? How to log?
[EMSE 2018]
[EMSE 2017] [EMSE 2017]
Error
Warn
Info
The log content &
containing blocks/files
can explain log levels
Mining development knowledge to
understand and support logging practices
38
Developers’
logging concerns?
[TSE under review]
Where to log?
When to update
log? How to log?
[EMSE 2018]
[EMSE 2017] [EMSE 2017]
Logging varies
across code topics
Error
Warn
Info
The source code &
code changes can
explain log changes
The log content &
containing blocks/files
can explain log levels
10 categories of
logging concerns
(e.g., misleading users)
References
§ Fu, Q., Lou, J. G., Lin, Q., Ding, R., Zhang, D., and Xie, T. (2013). Contextual analysis of program logs for
understanding system behaviors. In Proceedings of the 10th Working Conference on Mining Software
Repositories, MSR ’13, pages 397–400.
§ Xu, W., Huang, L., Fox, A., Patterson, D., and Jordan, M. I. (2009). Detecting large-scale system problems by
mining console logs. In Proceedings of the ACM SIGOPS 22nd Symposium on Operating Systems Principles,
SOSP ’09, pages 117–132.
§ Yuan, D., Mai, H., Xiong, W., Tan, L., Zhou, Y., and Pasupathy, S. (2010). Sherlog: Error diagnosis by connecting
clues from run-time logs. In Proceedings of the 15th International Conference on Architectural Support for
Programming Languages and Operating Systems, ASPLOS ’10, pages 143–154.
§ Yuan, D., Park, S., and Zhou, Y. (2012). Characterizing logging practices in open source software. In Proceedings
of the 34th International Conference on Software Engineering, ICSE ’12, pages 102–112.
§ Chen, B. and Jiang, Z. M. J. (2017). Characterizing logging practices in Java-based open source software projects
– a replication study in apache software foundation. Empirical Software Engineering, 22(1):330–374.
§ Shang, W., Jiang, Z. M., Adams, B., Hassan, A. E., Godfrey, M. W., Nasser, M., and Flora, P. (2014). An
exploratory study of the evolution of communicated information about the execution of large software
systems. Journal of Software: Evolution and Process, 26(1):3–26.
§ Fukushima, T., Kamei, Y., McIntosh, S., Yamashita, K., and Ubayashi, N. (2014). An empirical study of just-in-time
defect prediction using cross-project models. In Proceedings of the 11thWorking Conference onMining
Software Repositories, MSR 2014, pages 172–181.
39
Extra slides
40
Log()
Literature review
41
Mining
logging
code
Mining log messages
Improving
logging
code
Log()
Mining log messages
42
Understanding runtime behaviors
[Fu et al., 2013; Hassan et al., 2008; Shang et al., 2013]
Detecting anomaly conditions
[Xu et al., 2008, 2009; Fu et al., 2009; Jiang et al., 2008]
Diagnosing system failures
[Yuan et al, 2010; Syer et al., 2013]
Prior work highlights the importance of improving
logging quality
Mining logging code
43
Logging practices in open source projects
[Yuan et al., 2012; Chen and Jiang, 2017]
Logging practices in industry
[Fu et al, 2014; Pecchia et al., 2015]
Evolution of logging code
[Shang et al, 2011; Kabinna et al., 2016]
Log()
Developers spend much effort maintaining their logging
Software logging is a common practice
Improving logging code: proactive logging
44
Proactively adding logging info in the source
code
[Yuan et al., 2011, 2012; Zhao et al., 2017]
Log()
Producing excessive log information
Developers’ expertise and concerns are not considered
Improving logging code: learning to log
45
Learning statistical models to suggest where
to log
[Zhu et al., 2015; Lal and Sureka, 2016; Jia et al., 2018]
Ignoring logging patterns (e.g., log level, stack trace)
Log()
Focusing on one dim. of dev. knowledge (source code)
Providing logging suggestions as a post-dev. process
Logging stack traces can grow log files
very fast
46
Log.warn(msg) Log.warn(msg, e)
Logging a log
message + full stack
trace
Logging a log
message
Developers have difficulties to decide
whether to log stack traces
47
Missing stack trace
Improper logging
of stack trace
Learning from existing source code to
suggest whether to log a stack trace
48
Source
code
Source
code
Log(msg) Log(msg, e)
Source
code
Log(msg, ?)
Random Forest
Classifier
Log the
stack trace?
Six dimensions of
features
Log(msg, e)
Our models can effectively suggest whether
a stack trace is needed
49
0.85
0.94
0.9
0.86
0.5
0.6
0.7
0.8
0.9
1
AUC
The performance (AUC) of our Random
Forest models
Random guess

More Related Content

Similar to Mining Development Knowledge to Understand and Support Software Logging Practices (20)

PPTX
Log Engineering: Towards Systematic Log Mining to Support the Development of ...
SAIL_QU
 
PPTX
Log Engineering: Towards Systematic Log Mining to Support the Development of ...
SAIL_QU
 
PDF
Logging node.js global summit
Marcos Bérgamo
 
PDF
Are logs a software engineer’s best friend? Yes -- follow these best practices
Geshan Manandhar
 
KEY
Message passing
Damien Krotkine
 
PDF
A Tool for Rejuvenating Feature Logging Levels via Git Histories and Degree o...
Raffi Khatchadourian
 
PPTX
Application logging for fun and profit
Jane Prusakova
 
PDF
Application Logging for large systems
Jane Prusakova
 
PDF
Helpful logging with python
roskakori
 
PDF
Helpful logging with Java
roskakori
 
PDF
Un-broken Logging - TechnologyUG - Leeds - Matthew Skelton
Skelton Thatcher Consulting Ltd
 
PDF
Building of systems of automatic C/C++ code logging
PVS-Studio
 
PDF
Day 2 05 - steve feldman - logging matters
Steve Feldman
 
PDF
Systems se
Franco Bressan
 
PDF
Un-broken Logging - Operability.io 2015 - Matthew Skelton
Skelton Thatcher Consulting Ltd
 
PDF
Un-broken logging - the foundation of software operability - Operability.io -...
Matthew Skelton
 
PPT
Chelberg ptcuser 2010
Clay Helberg
 
PDF
Automated Evolution of Feature Logging Statement Levels Using Git Histories a...
Raffi Khatchadourian
 
PPTX
Designing and Implementing Effective Logging Strategies
AndreaCapolei1
 
PDF
P&MSP2012 - Logging Frameworks
Daniele Dell'Aglio
 
Log Engineering: Towards Systematic Log Mining to Support the Development of ...
SAIL_QU
 
Log Engineering: Towards Systematic Log Mining to Support the Development of ...
SAIL_QU
 
Logging node.js global summit
Marcos Bérgamo
 
Are logs a software engineer’s best friend? Yes -- follow these best practices
Geshan Manandhar
 
Message passing
Damien Krotkine
 
A Tool for Rejuvenating Feature Logging Levels via Git Histories and Degree o...
Raffi Khatchadourian
 
Application logging for fun and profit
Jane Prusakova
 
Application Logging for large systems
Jane Prusakova
 
Helpful logging with python
roskakori
 
Helpful logging with Java
roskakori
 
Un-broken Logging - TechnologyUG - Leeds - Matthew Skelton
Skelton Thatcher Consulting Ltd
 
Building of systems of automatic C/C++ code logging
PVS-Studio
 
Day 2 05 - steve feldman - logging matters
Steve Feldman
 
Systems se
Franco Bressan
 
Un-broken Logging - Operability.io 2015 - Matthew Skelton
Skelton Thatcher Consulting Ltd
 
Un-broken logging - the foundation of software operability - Operability.io -...
Matthew Skelton
 
Chelberg ptcuser 2010
Clay Helberg
 
Automated Evolution of Feature Logging Statement Levels Using Git Histories a...
Raffi Khatchadourian
 
Designing and Implementing Effective Logging Strategies
AndreaCapolei1
 
P&MSP2012 - Logging Frameworks
Daniele Dell'Aglio
 

More from SAIL_QU (20)

PDF
Studying the Integration Practices and the Evolution of Ad Libraries in the G...
SAIL_QU
 
PDF
Studying the Dialogue Between Users and Developers of Free Apps in the Google...
SAIL_QU
 
PPTX
Improving the testing efficiency of selenium-based load tests
SAIL_QU
 
PDF
Studying User-Developer Interactions Through the Distribution and Reviewing M...
SAIL_QU
 
PDF
Studying online distribution platforms for games through the mining of data f...
SAIL_QU
 
PPTX
Understanding the Factors for Fast Answers in Technical Q&A Websites: An Empi...
SAIL_QU
 
PDF
Investigating the Challenges in Selenium Usage and Improving the Testing Effi...
SAIL_QU
 
PDF
The Impact of Task Granularity on Co-evolution Analyses
SAIL_QU
 
PPTX
A Framework for Evaluating the Results of the SZZ Approach for Identifying Bu...
SAIL_QU
 
PPTX
How are Discussions Associated with Bug Reworking? An Empirical Study on Open...
SAIL_QU
 
PPTX
A Study of the Relation of Mobile Device Attributes with the User-Perceived Q...
SAIL_QU
 
PDF
A Large-Scale Study of the Impact of Feature Selection Techniques on Defect C...
SAIL_QU
 
PPTX
Studying the Dialogue Between Users and Developers of Free Apps in the Google...
SAIL_QU
 
PDF
What Do Programmers Know about Software Energy Consumption?
SAIL_QU
 
PPTX
Threshold for Size and Complexity Metrics: A Case Study from the Perspective ...
SAIL_QU
 
PDF
Revisiting the Experimental Design Choices for Approaches for the Automated R...
SAIL_QU
 
PPTX
Measuring Program Comprehension: A Large-Scale Field Study with Professionals
SAIL_QU
 
PPTX
On the Unreliability of Bug Severity Data
SAIL_QU
 
PPT
On the Link Between Mobile App Quality and User Reviews
SAIL_QU
 
PDF
Mining Software Engineering Data
SAIL_QU
 
Studying the Integration Practices and the Evolution of Ad Libraries in the G...
SAIL_QU
 
Studying the Dialogue Between Users and Developers of Free Apps in the Google...
SAIL_QU
 
Improving the testing efficiency of selenium-based load tests
SAIL_QU
 
Studying User-Developer Interactions Through the Distribution and Reviewing M...
SAIL_QU
 
Studying online distribution platforms for games through the mining of data f...
SAIL_QU
 
Understanding the Factors for Fast Answers in Technical Q&A Websites: An Empi...
SAIL_QU
 
Investigating the Challenges in Selenium Usage and Improving the Testing Effi...
SAIL_QU
 
The Impact of Task Granularity on Co-evolution Analyses
SAIL_QU
 
A Framework for Evaluating the Results of the SZZ Approach for Identifying Bu...
SAIL_QU
 
How are Discussions Associated with Bug Reworking? An Empirical Study on Open...
SAIL_QU
 
A Study of the Relation of Mobile Device Attributes with the User-Perceived Q...
SAIL_QU
 
A Large-Scale Study of the Impact of Feature Selection Techniques on Defect C...
SAIL_QU
 
Studying the Dialogue Between Users and Developers of Free Apps in the Google...
SAIL_QU
 
What Do Programmers Know about Software Energy Consumption?
SAIL_QU
 
Threshold for Size and Complexity Metrics: A Case Study from the Perspective ...
SAIL_QU
 
Revisiting the Experimental Design Choices for Approaches for the Automated R...
SAIL_QU
 
Measuring Program Comprehension: A Large-Scale Field Study with Professionals
SAIL_QU
 
On the Unreliability of Bug Severity Data
SAIL_QU
 
On the Link Between Mobile App Quality and User Reviews
SAIL_QU
 
Mining Software Engineering Data
SAIL_QU
 
Ad

Recently uploaded (20)

PDF
UNIT-4-FEEDBACK AMPLIFIERS AND OSCILLATORS (1).pdf
Sridhar191373
 
PDF
Zilliz Cloud Demo for performance and scale
Zilliz
 
PDF
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
PPTX
Structural Functiona theory this important for the theorist
cagumaydanny26
 
PPTX
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
PDF
Additional Information in midterm CPE024 (1).pdf
abolisojoy
 
PDF
A presentation on the Urban Heat Island Effect
studyfor7hrs
 
PPTX
Presentation on Foundation Design for Civil Engineers.pptx
KamalKhan563106
 
PPTX
MPMC_Module-2 xxxxxxxxxxxxxxxxxxxxx.pptx
ShivanshVaidya5
 
PPTX
site survey architecture student B.arch.
sri02032006
 
PPTX
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
PPTX
Break Statement in Programming with 6 Real Examples
manojpoojary2004
 
PPTX
ISO/IEC JTC 1/WG 9 (MAR) Convenor Report
Kurata Takeshi
 
PPTX
Benefits_^0_Challigi😙🏡💐8fenges[1].pptx
akghostmaker
 
PDF
Book.pdf01_Intro.ppt algorithm for preperation stu used
archu26
 
PPTX
NEUROMOROPHIC nu iajwojeieheueueueu.pptx
knkoodalingam39
 
PPT
Oxygen Co2 Transport in the Lungs(Exchange og gases)
SUNDERLINSHIBUD
 
PDF
BioSensors glucose monitoring, cholestrol
nabeehasahar1
 
PDF
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
PDF
monopile foundation seminar topic for civil engineering students
Ahina5
 
UNIT-4-FEEDBACK AMPLIFIERS AND OSCILLATORS (1).pdf
Sridhar191373
 
Zilliz Cloud Demo for performance and scale
Zilliz
 
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
Structural Functiona theory this important for the theorist
cagumaydanny26
 
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
Additional Information in midterm CPE024 (1).pdf
abolisojoy
 
A presentation on the Urban Heat Island Effect
studyfor7hrs
 
Presentation on Foundation Design for Civil Engineers.pptx
KamalKhan563106
 
MPMC_Module-2 xxxxxxxxxxxxxxxxxxxxx.pptx
ShivanshVaidya5
 
site survey architecture student B.arch.
sri02032006
 
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
Break Statement in Programming with 6 Real Examples
manojpoojary2004
 
ISO/IEC JTC 1/WG 9 (MAR) Convenor Report
Kurata Takeshi
 
Benefits_^0_Challigi😙🏡💐8fenges[1].pptx
akghostmaker
 
Book.pdf01_Intro.ppt algorithm for preperation stu used
archu26
 
NEUROMOROPHIC nu iajwojeieheueueueu.pptx
knkoodalingam39
 
Oxygen Co2 Transport in the Lungs(Exchange og gases)
SUNDERLINSHIBUD
 
BioSensors glucose monitoring, cholestrol
nabeehasahar1
 
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
monopile foundation seminar topic for civil engineering students
Ahina5
 
Ad

Mining Development Knowledge to Understand and Support Software Logging Practices

  • 1. Mining Development Knowledge to Understand and Support Software Logging Practices Heng Li Supervisor: Dr. Ahmed E. Hassan Software Analysis & Intelligence Lab (SAIL) Queen’s University, Canada
  • 2. Developers insert logging code that produces log messages at runtime 2 Log() Logging code Log messages Software system Log.info(“Stopping server on ” + port); 2016-07-23 17:56:16 INFO Stopping server on 8032 Log messages record valuable runtime information
  • 3. Diagnose failures Logging is critical for software maintenance Detect anomalies Log messages are widely used in software maintenance efforts 3 Understand runtime behaviors Fu et al., Contextual analysis of program logs for understanding system behaviors. MSR ‘13 Yuan et al., Sherlog: Error diagnosis by connecting clues from run-time logs. ASPLOS ‘10 Xu et al., Detecting large-scale system problems by mining console logs. SOSP ‘09
  • 4. Developers have difficulties deciding on appropriate logging code 4 “A lot of log noise” “Slowing down perf by 20%” “Missing an error log” Developers spend a significant amount of efforts maintaining their logging code § Logging practices in open source projects [Yuan et al., 2012; Chen and Jiang, 2017] § Logging practices in industry [Shang et al, 2014; Fu et al, 2014] Prior work
  • 5. Development knowledge explains the development of logging code 5 − LOG.info(msg); + LOG.warn(msg); To help users identify a problem LOG.warn(msg); What How Why Change historySource code Issue reports
  • 6. Thesis statement Development knowledge can help us understand current logging practices and develop useful tools to support such logging practices 6 Change historySource code Issue reports Development knowledge
  • 7. Mining development knowledge to understand and support logging practices 7 Developers’ logging concerns? [TSE under review] Where to log? When to update log? How to log? [EMSE 2018] [EMSE 2017] [EMSE 2017] Error Warn Info
  • 8. Mining development knowledge to understand and support logging practices 8 Developers’ logging concerns? [TSE under review] Where to log? When to update log? How to log? [EMSE 2018] [EMSE 2017] [EMSE 2017] Error Warn Info
  • 9. Developers communicate their logging concerns in issue reports 9 Logging cost: performance overhead Remove a logging statement
  • 10. Developers communicate their logging concerns in issue reports 10 Add a logging statement Logging benefit: exposing runtime problems
  • 11. We study logging-related issues reports to understand developer’s logging concerns 11 Logging issue reports Logging concerns Automated & manual filtering Qualitative analysis
  • 12. What are developers’ logging concerns? 12 Logging Benefits § Assisting in debugging Logging Costs § Excessive log information Research opportunities Leverage Minimize Frequency § Providing runtime perf § Exposing runtime problems § Bookkeeping § Showing execution progress § Exposing unnecessary details § Misleading end users § Performance overhead § Exposing sensitive info
  • 13. Mining development knowledge to understand and support logging practices 13 Developers’ logging concerns? [TSE under review] Where to log? When to update log? How to log? [EMSE 2018] [EMSE 2017] [EMSE 2017] Error Warn Info 10 categories of logging concerns (e.g., misleading users)
  • 14. Mining development knowledge to understand and support logging practices 14 Developers’ logging concerns? [TSE under review] Where to log? When to update log? How to log? [EMSE 2018] [EMSE 2017] [EMSE 2017] Error Warn Info
  • 15. Some code topics are more likely to need logging statements 15 Examples of JIRA issues that require developers to log the topic of “connections” [EMSE 2018]
  • 16. Can code topics explain where to log? Topic: “connection” Logging statement [EMSE 2018] 16 We extract the code topics and logging statements for each code snippet (method level)
  • 17. We use LDA to extract code topics Logging statement [EMSE 2018] 17 Tokenization Topic model (LDA) queue, connection Topic: “connection”
  • 18. A small number of topics are much more likely to be logged Topic: “connection” Logging statement The most log-intensive topics usually capture communication between machines (e.g., ”connection”) or interactions between threads (e.g., “thread interruption”) [EMSE 2018] 18
  • 19. We combine both the structure and topic info to explain where to log Topic: “connection” Logging statement Structure info: lines of code, complexity, control flow statements, etc. [EMSE 2018] 19
  • 20. We combine both the structure and topic info to explain where to log Topic: “connection” Logging statement Structure info: lines of code, complexity, control flow statements, etc. LASSO model [EMSE 2018] 20
  • 21. Code topics bring additional explanatory power (up to 13% AUC improvement) 21 0.82 0.86 0.8 0.86 0.83 0.96 0.87 0.94 0.9 0.9 0.88 0.99 0.5 0.6 0.7 0.8 0.9 1 Structure info Structure & topic info AUC The performance (AUC) of our LASSO models Random guess [EMSE 2018]
  • 22. Mining development knowledge to understand and support logging practices 22 Developers’ logging concerns? [TSE under review] Where to log? When to update log? How to log? [EMSE 2018] [EMSE 2017] [EMSE 2017] Error Warn Info Logging varies across code topics
  • 23. Mining development knowledge to understand and support logging practices 23 Developers’ logging concerns? [TSE under review] Where to log? When to update log? How to log? [EMSE 2018] [EMSE 2017] [EMSE 2017] Error Warn Info
  • 24. Developers have difficulties to make appropriate log changes 24 Developers usually forget to change logging code when they change their code; in many cases, logging code is written as “after-thoughts” after a failure happens and logs are needed [Yuan et al., 2012] Commit n Commit n+1 Code changes Log changes Version k Debugging difficulties Code change history Maintenance efforts
  • 25. Learning from the code change history to provide log change suggestions 25 [EMSE 2017] Code Code Log Code Log ? Commit 1 Commit 2 Commit n… Code changes without log changes Code changes with log changes Do we need to change logs? Code change history
  • 26. LOG? Providing automated suggestions for log changes when developers change the code 26 Random Forest Classifier Log change suggestions Three dimensions 25 metrics Change metrics Historical metrics Product metrics [EMSE 2017] Code
  • 27. Our models can effectively suggest whether a log change is needed 27 0.84 0.91 0.86 0.88 0.5 0.6 0.7 0.8 0.9 1 AUC The performance (AUC) of our Random Forest models Random guess [EMSE 2017]
  • 28. LOG? The source code and code changes are important for explaining log changes 28 Log change suggestions Three dimensions 25 metrics Change metrics Historical metrics Product metrics [EMSE 2017] Code Explain
  • 29. Mining development knowledge to understand and support logging practices 29 Developers’ logging concerns? [TSE under review] Where to log? When to update log? How to log? [EMSE 2018] [EMSE 2017] [EMSE 2017] Error Warn Info The source code & code changes can explain log changes
  • 30. Mining development knowledge to understand and support logging practices 30 Developers’ logging concerns? [TSE under review] Where to log? When to update log? How to log? [EMSE 2018] [EMSE 2017] [EMSE 2017] Error Warn Info
  • 31. Log levels are used to disable some verbose log messages while enabling important ones 31 Trace Debug Info Warn Error Fatal Less verbose levels (higher levels) More verbose levels (lower levels) Log.error(“message”) Log level
  • 32. Improper log levels can have many negative impacts 32 “…tends to generate a lot of log noise…” “These warnings worry users” Developers spend much efforts adjusting log levels [Yuan et al., 2012]
  • 33. Learning from the code change history to provide log level suggestions 33 [EMSE 2017] Commit 1 Commit 2 Commit n… Code change history Log.warn(msg) Log.info(msg) Log. ? (msg) Log.error(msg) Which log level to use?
  • 34. Providing automated suggestions for log levels when developers add logging code 34 Logging statement metrics Containing block metrics Containing file metrics Code change metrics Historical change metrics Trace Debug Info Warn Error Fatal Ordinal Regression Model [EMSE 2017]
  • 35. Ordinal regression models can effectively model log levels 35 0.76 0.78 0.81 0.75 0.5 0.6 0.7 0.8 0.9 The performance (AUC) of our Ordinal Regression Models AUC Random guess [EMSE 2017]
  • 36. The content of a logging statements and the containing block/file explain its log level 36 Logging statement metrics Containing block metrics Containing file metrics Code change metrics Historical change metrics Trace Debug Info Warn Error Fatal [EMSE 2017] Explain
  • 37. Mining development knowledge to understand and support logging practices 37 Developers’ logging concerns? [TSE under review] Where to log? When to update log? How to log? [EMSE 2018] [EMSE 2017] [EMSE 2017] Error Warn Info The log content & containing blocks/files can explain log levels
  • 38. Mining development knowledge to understand and support logging practices 38 Developers’ logging concerns? [TSE under review] Where to log? When to update log? How to log? [EMSE 2018] [EMSE 2017] [EMSE 2017] Logging varies across code topics Error Warn Info The source code & code changes can explain log changes The log content & containing blocks/files can explain log levels 10 categories of logging concerns (e.g., misleading users)
  • 39. References § Fu, Q., Lou, J. G., Lin, Q., Ding, R., Zhang, D., and Xie, T. (2013). Contextual analysis of program logs for understanding system behaviors. In Proceedings of the 10th Working Conference on Mining Software Repositories, MSR ’13, pages 397–400. § Xu, W., Huang, L., Fox, A., Patterson, D., and Jordan, M. I. (2009). Detecting large-scale system problems by mining console logs. In Proceedings of the ACM SIGOPS 22nd Symposium on Operating Systems Principles, SOSP ’09, pages 117–132. § Yuan, D., Mai, H., Xiong, W., Tan, L., Zhou, Y., and Pasupathy, S. (2010). Sherlog: Error diagnosis by connecting clues from run-time logs. In Proceedings of the 15th International Conference on Architectural Support for Programming Languages and Operating Systems, ASPLOS ’10, pages 143–154. § Yuan, D., Park, S., and Zhou, Y. (2012). Characterizing logging practices in open source software. In Proceedings of the 34th International Conference on Software Engineering, ICSE ’12, pages 102–112. § Chen, B. and Jiang, Z. M. J. (2017). Characterizing logging practices in Java-based open source software projects – a replication study in apache software foundation. Empirical Software Engineering, 22(1):330–374. § Shang, W., Jiang, Z. M., Adams, B., Hassan, A. E., Godfrey, M. W., Nasser, M., and Flora, P. (2014). An exploratory study of the evolution of communicated information about the execution of large software systems. Journal of Software: Evolution and Process, 26(1):3–26. § Fukushima, T., Kamei, Y., McIntosh, S., Yamashita, K., and Ubayashi, N. (2014). An empirical study of just-in-time defect prediction using cross-project models. In Proceedings of the 11thWorking Conference onMining Software Repositories, MSR 2014, pages 172–181. 39
  • 41. Log() Literature review 41 Mining logging code Mining log messages Improving logging code Log()
  • 42. Mining log messages 42 Understanding runtime behaviors [Fu et al., 2013; Hassan et al., 2008; Shang et al., 2013] Detecting anomaly conditions [Xu et al., 2008, 2009; Fu et al., 2009; Jiang et al., 2008] Diagnosing system failures [Yuan et al, 2010; Syer et al., 2013] Prior work highlights the importance of improving logging quality
  • 43. Mining logging code 43 Logging practices in open source projects [Yuan et al., 2012; Chen and Jiang, 2017] Logging practices in industry [Fu et al, 2014; Pecchia et al., 2015] Evolution of logging code [Shang et al, 2011; Kabinna et al., 2016] Log() Developers spend much effort maintaining their logging Software logging is a common practice
  • 44. Improving logging code: proactive logging 44 Proactively adding logging info in the source code [Yuan et al., 2011, 2012; Zhao et al., 2017] Log() Producing excessive log information Developers’ expertise and concerns are not considered
  • 45. Improving logging code: learning to log 45 Learning statistical models to suggest where to log [Zhu et al., 2015; Lal and Sureka, 2016; Jia et al., 2018] Ignoring logging patterns (e.g., log level, stack trace) Log() Focusing on one dim. of dev. knowledge (source code) Providing logging suggestions as a post-dev. process
  • 46. Logging stack traces can grow log files very fast 46 Log.warn(msg) Log.warn(msg, e) Logging a log message + full stack trace Logging a log message
  • 47. Developers have difficulties to decide whether to log stack traces 47 Missing stack trace Improper logging of stack trace
  • 48. Learning from existing source code to suggest whether to log a stack trace 48 Source code Source code Log(msg) Log(msg, e) Source code Log(msg, ?) Random Forest Classifier Log the stack trace? Six dimensions of features Log(msg, e)
  • 49. Our models can effectively suggest whether a stack trace is needed 49 0.85 0.94 0.9 0.86 0.5 0.6 0.7 0.8 0.9 1 AUC The performance (AUC) of our Random Forest models Random guess