SlideShare a Scribd company logo
Logs
Objective
• all activities that affect user state or
balances are formally trackedAuditable
• it’s possible to determine where an
activity occurs in all tiers of the
application
Traceable
• logs cannot be overwritten or tampered
with by local or remote users
High
integrity
Message Priorities/Levels
• Severe errors that cause premature termination.fatal
• Other runtime errors or unexpected conditions.error
• are undesirable or unexpected, but not necessarily
"wrong".Warn
• Interesting runtime events (startup/shutdown).Info
• detailed information on the flow through the system.Debug
• more detailed information.Trace
What to log?
Log all the things
Work Smarter, not Harder
Default Message Priority/Level
By default the message priority
should be no lower than info.
That is, by default debug message
should not be seen in the logs.
Default production log level
WARNING
Where to define logger layout?
• private static Logger log = Logger.getLogger(
MyClass.class )
– log.error()
– log.warn()
– log.info()
– log.debug()
• "%r [%t] %-5p %c - %m%n"
– 176 [main] INFO org.foo.Bar - Located nearest gas
station.
What format to use?
• A SINGLE LINE
• Timestamps with timezone, to the
millisecond or nanosecond
• Class name + line number
• Meaningful context
Best practices for app
• Do not allow exceptions to go
unhandled/reach the browser
• Display custom error pages to users with an
email link for feedback
• Do not enable “Robust Exception Information”
in production.
• Rotate log files to keep them current
Use parameterized logging
• LOG.debug("Method called with arg " + arg);
• BAD: string varies with argument
Use parameterized logging
• if (LOG.isDebugEnabled()) {
LOG.debug("Method called with arg {}", arg);
• BAD: code clutter
Use parameterized logging
• LOG.debug("arg is {}", arg);
• BAD: wrong level of language, this would be
okay on TRACE
Use parameterized logging
• LOG.debug("Method called with arg {}", arg);
• GOOD: string literal, no dynamic objects
Exception example
• catch (SomeException ex) { LOG.warn("Failed
to do something with {}, continuing", arg, ex);
}
• GOOD: note how there is no "{}" for ex
Provide useful event context
• LOG.debug(arg.toString());
• VERY BAD:
– no context provided
– non-constant message string
– assumes useful toString()
Provide useful event context
• LOG.debug("{}", arg);
• VERY BAD
– no context provided
Provide useful event context
• try { doSomething(arg); ... }
catch (SomeException ex) { }
• COMPLETELY BAD
– silently ignoring errors!!!
Provide useful event context
• try { doSomething(arg);}
catch (SomeException ex) {
LOG.warn(ex.getMessage()); }
• EXTREMELY BAD
– message is not constant
– no context is provided
– ex.getCause() is lost
– call stack is lost
Provide useful event context
• try { doSomething(arg); ... }
catch (SomeException ex) {
LOG.warn("Failed to do something with {},
ignoring it", arg, ex); }
• GOOD
– string literal
– we explain what we tried to do
– we pass along information we have about the failure
– we explain that we recovered from the failure
Provide useful event context
• try { doSomething(arg); ... }
catch (SomeException ex) { LOG.error("Failed to do
something with {}", arg, ex);
throw new RuntimeException("Failed to do
something", ex); }
• GOOD
– string literal
– we explain what we tried to do
– we pass along information we have about the failure
– we escalate the failure to our caller
– we also 'chain' the exception so it is not lost and can be
correlated
Anything else?
• Separate files for different areas of interest
• Always Log To Local Disk
• http://juliusdavies.ca/logging.html

More Related Content

Viewers also liked

13 Signs You Might Be A Bad Boss
13 Signs You Might Be A Bad Boss13 Signs You Might Be A Bad Boss
13 Signs You Might Be A Bad Boss
Officevibe
 
10 Shocking Stats About Disengaged Employees
10 Shocking Stats About Disengaged Employees10 Shocking Stats About Disengaged Employees
10 Shocking Stats About Disengaged Employees
Officevibe
 
20 Inspirational Leadership Quotes
20 Inspirational Leadership Quotes20 Inspirational Leadership Quotes
20 Inspirational Leadership Quotes
Officevibe
 
Do You Struggle With Employee Recognition?
Do You Struggle With Employee Recognition?Do You Struggle With Employee Recognition?
Do You Struggle With Employee Recognition?
Elodie A.
 
BigWeatherGear Group and Corporate Services Brochure 2013
BigWeatherGear Group and Corporate Services Brochure 2013BigWeatherGear Group and Corporate Services Brochure 2013
BigWeatherGear Group and Corporate Services Brochure 2013
Kristin Matson
 
Shall we play a game?
Shall we play a game?Shall we play a game?
Shall we play a game?
Maciej Lasyk
 
The Productivity Secret Of The Best Leaders
The Productivity Secret Of The Best LeadersThe Productivity Secret Of The Best Leaders
The Productivity Secret Of The Best Leaders
Officevibe
 
10 Ways Your Boss Kills Employee Motivation
10 Ways Your Boss Kills Employee Motivation10 Ways Your Boss Kills Employee Motivation
10 Ways Your Boss Kills Employee Motivation
Officevibe
 

Viewers also liked (8)

13 Signs You Might Be A Bad Boss
13 Signs You Might Be A Bad Boss13 Signs You Might Be A Bad Boss
13 Signs You Might Be A Bad Boss
 
10 Shocking Stats About Disengaged Employees
10 Shocking Stats About Disengaged Employees10 Shocking Stats About Disengaged Employees
10 Shocking Stats About Disengaged Employees
 
20 Inspirational Leadership Quotes
20 Inspirational Leadership Quotes20 Inspirational Leadership Quotes
20 Inspirational Leadership Quotes
 
Do You Struggle With Employee Recognition?
Do You Struggle With Employee Recognition?Do You Struggle With Employee Recognition?
Do You Struggle With Employee Recognition?
 
BigWeatherGear Group and Corporate Services Brochure 2013
BigWeatherGear Group and Corporate Services Brochure 2013BigWeatherGear Group and Corporate Services Brochure 2013
BigWeatherGear Group and Corporate Services Brochure 2013
 
Shall we play a game?
Shall we play a game?Shall we play a game?
Shall we play a game?
 
The Productivity Secret Of The Best Leaders
The Productivity Secret Of The Best LeadersThe Productivity Secret Of The Best Leaders
The Productivity Secret Of The Best Leaders
 
10 Ways Your Boss Kills Employee Motivation
10 Ways Your Boss Kills Employee Motivation10 Ways Your Boss Kills Employee Motivation
10 Ways Your Boss Kills Employee Motivation
 

Similar to Logs

Cashing in on logging and exception data
Cashing in on logging and exception dataCashing in on logging and exception data
Cashing in on logging and exception data
Stackify
 
Coding for production
Coding for productionCoding for production
Coding for production
jehiah
 
Monitoring and Debugging your Live Applications
Monitoring and Debugging your Live ApplicationsMonitoring and Debugging your Live Applications
Monitoring and Debugging your Live Applications
Robert Coup
 
Java 8 and beyond, a scala story
Java 8 and beyond, a scala storyJava 8 and beyond, a scala story
Java 8 and beyond, a scala story
ittaiz
 
10 Tips to improve your application logs
10 Tips to improve your application logs10 Tips to improve your application logs
10 Tips to improve your application logs
Vanessa Gomes
 
Instrumentation of Software Systems
Instrumentation of Software SystemsInstrumentation of Software Systems
Instrumentation of Software Systems
James Hill
 
Presentation log4 j
Presentation log4 jPresentation log4 j
Presentation log4 j
Sylvain Bouchard
 
Presentation log4 j
Presentation log4 jPresentation log4 j
Presentation log4 j
Sylvain Bouchard
 
Logstash and friends
Logstash and friendsLogstash and friends
Logstash and friends
Julien Pivotto
 
Monitor all the things - Confoo
Monitor all the things - ConfooMonitor all the things - Confoo
Monitor all the things - Confoo
felixtrepanier
 
Test automation with Cucumber-JVM
Test automation with Cucumber-JVMTest automation with Cucumber-JVM
Test automation with Cucumber-JVM
Alan Parkinson
 
Docker Logging and analysing with Elastic Stack
Docker Logging and analysing with Elastic StackDocker Logging and analysing with Elastic Stack
Docker Logging and analysing with Elastic Stack
Jakub Hajek
 
Docker Logging and analysing with Elastic Stack - Jakub Hajek
Docker Logging and analysing with Elastic Stack - Jakub Hajek Docker Logging and analysing with Elastic Stack - Jakub Hajek
Docker Logging and analysing with Elastic Stack - Jakub Hajek
PROIDEA
 
Elk with Openstack
Elk with OpenstackElk with Openstack
Elk with Openstack
Arun prasath
 
Logstash
LogstashLogstash
Logstash
琛琳 饶
 
Helpful logging with Java
Helpful logging with JavaHelpful logging with Java
Helpful logging with Java
roskakori
 
ELK stack at weibo.com
ELK stack at weibo.comELK stack at weibo.com
ELK stack at weibo.com
琛琳 饶
 
Debugging webOS applications
Debugging webOS applicationsDebugging webOS applications
Debugging webOS applications
fpatton
 

Similar to Logs (20)

Cashing in on logging and exception data
Cashing in on logging and exception dataCashing in on logging and exception data
Cashing in on logging and exception data
 
Coding for production
Coding for productionCoding for production
Coding for production
 
Monitoring and Debugging your Live Applications
Monitoring and Debugging your Live ApplicationsMonitoring and Debugging your Live Applications
Monitoring and Debugging your Live Applications
 
Logging
LoggingLogging
Logging
 
Java 8 and beyond, a scala story
Java 8 and beyond, a scala storyJava 8 and beyond, a scala story
Java 8 and beyond, a scala story
 
10 Tips to improve your application logs
10 Tips to improve your application logs10 Tips to improve your application logs
10 Tips to improve your application logs
 
Instrumentation of Software Systems
Instrumentation of Software SystemsInstrumentation of Software Systems
Instrumentation of Software Systems
 
Presentation log4 j
Presentation log4 jPresentation log4 j
Presentation log4 j
 
Presentation log4 j
Presentation log4 jPresentation log4 j
Presentation log4 j
 
Logstash and friends
Logstash and friendsLogstash and friends
Logstash and friends
 
Monitor all the things - Confoo
Monitor all the things - ConfooMonitor all the things - Confoo
Monitor all the things - Confoo
 
Test automation with Cucumber-JVM
Test automation with Cucumber-JVMTest automation with Cucumber-JVM
Test automation with Cucumber-JVM
 
Docker Logging and analysing with Elastic Stack
Docker Logging and analysing with Elastic StackDocker Logging and analysing with Elastic Stack
Docker Logging and analysing with Elastic Stack
 
Docker Logging and analysing with Elastic Stack - Jakub Hajek
Docker Logging and analysing with Elastic Stack - Jakub Hajek Docker Logging and analysing with Elastic Stack - Jakub Hajek
Docker Logging and analysing with Elastic Stack - Jakub Hajek
 
Elk with Openstack
Elk with OpenstackElk with Openstack
Elk with Openstack
 
Java Logging
Java LoggingJava Logging
Java Logging
 
Logstash
LogstashLogstash
Logstash
 
Helpful logging with Java
Helpful logging with JavaHelpful logging with Java
Helpful logging with Java
 
ELK stack at weibo.com
ELK stack at weibo.comELK stack at weibo.com
ELK stack at weibo.com
 
Debugging webOS applications
Debugging webOS applicationsDebugging webOS applications
Debugging webOS applications
 

More from Hanokh Aloni

NWD Total commander for fun and profit!!!
NWD Total commander for fun and profit!!!NWD Total commander for fun and profit!!!
NWD Total commander for fun and profit!!!
Hanokh Aloni
 
CI CD OPS WHATHAVEYOU
CI CD OPS WHATHAVEYOUCI CD OPS WHATHAVEYOU
CI CD OPS WHATHAVEYOU
Hanokh Aloni
 
How to write proper GIT commit messages.pptx
How to write proper GIT commit messages.pptxHow to write proper GIT commit messages.pptx
How to write proper GIT commit messages.pptx
Hanokh Aloni
 
Architectural kata 0 of n.pptx
Architectural kata 0 of n.pptxArchitectural kata 0 of n.pptx
Architectural kata 0 of n.pptx
Hanokh Aloni
 
Code smells (1).pptx
Code smells (1).pptxCode smells (1).pptx
Code smells (1).pptx
Hanokh Aloni
 
NWD the73js.pptx
NWD the73js.pptxNWD the73js.pptx
NWD the73js.pptx
Hanokh Aloni
 
top developer mistakes
top developer mistakes top developer mistakes
top developer mistakes
Hanokh Aloni
 
Things senior developers should know
Things senior developers should knowThings senior developers should know
Things senior developers should know
Hanokh Aloni
 
Cynefin framework in software engineering
Cynefin framework in software engineeringCynefin framework in software engineering
Cynefin framework in software engineering
Hanokh Aloni
 
Microservices
MicroservicesMicroservices
Microservices
Hanokh Aloni
 
Wcbpijwbpij new
Wcbpijwbpij newWcbpijwbpij new
Wcbpijwbpij new
Hanokh Aloni
 
Trunk based vs git flow
Trunk based vs git flowTrunk based vs git flow
Trunk based vs git flow
Hanokh Aloni
 
How to write unmaintainable code
How to write unmaintainable codeHow to write unmaintainable code
How to write unmaintainable code
Hanokh Aloni
 
How i learned to stop worrying and love the logs
How i learned to stop worrying and love the logsHow i learned to stop worrying and love the logs
How i learned to stop worrying and love the logs
Hanokh Aloni
 
Game is ggj2018 presentation
Game is ggj2018 presentationGame is ggj2018 presentation
Game is ggj2018 presentation
Hanokh Aloni
 
Microservices
MicroservicesMicroservices
Microservices
Hanokh Aloni
 
Game is ggj2017 presentation
Game is ggj2017 presentationGame is ggj2017 presentation
Game is ggj2017 presentation
Hanokh Aloni
 
02 terms and issues
02 terms and issues02 terms and issues
02 terms and issues
Hanokh Aloni
 

More from Hanokh Aloni (18)

NWD Total commander for fun and profit!!!
NWD Total commander for fun and profit!!!NWD Total commander for fun and profit!!!
NWD Total commander for fun and profit!!!
 
CI CD OPS WHATHAVEYOU
CI CD OPS WHATHAVEYOUCI CD OPS WHATHAVEYOU
CI CD OPS WHATHAVEYOU
 
How to write proper GIT commit messages.pptx
How to write proper GIT commit messages.pptxHow to write proper GIT commit messages.pptx
How to write proper GIT commit messages.pptx
 
Architectural kata 0 of n.pptx
Architectural kata 0 of n.pptxArchitectural kata 0 of n.pptx
Architectural kata 0 of n.pptx
 
Code smells (1).pptx
Code smells (1).pptxCode smells (1).pptx
Code smells (1).pptx
 
NWD the73js.pptx
NWD the73js.pptxNWD the73js.pptx
NWD the73js.pptx
 
top developer mistakes
top developer mistakes top developer mistakes
top developer mistakes
 
Things senior developers should know
Things senior developers should knowThings senior developers should know
Things senior developers should know
 
Cynefin framework in software engineering
Cynefin framework in software engineeringCynefin framework in software engineering
Cynefin framework in software engineering
 
Microservices
MicroservicesMicroservices
Microservices
 
Wcbpijwbpij new
Wcbpijwbpij newWcbpijwbpij new
Wcbpijwbpij new
 
Trunk based vs git flow
Trunk based vs git flowTrunk based vs git flow
Trunk based vs git flow
 
How to write unmaintainable code
How to write unmaintainable codeHow to write unmaintainable code
How to write unmaintainable code
 
How i learned to stop worrying and love the logs
How i learned to stop worrying and love the logsHow i learned to stop worrying and love the logs
How i learned to stop worrying and love the logs
 
Game is ggj2018 presentation
Game is ggj2018 presentationGame is ggj2018 presentation
Game is ggj2018 presentation
 
Microservices
MicroservicesMicroservices
Microservices
 
Game is ggj2017 presentation
Game is ggj2017 presentationGame is ggj2017 presentation
Game is ggj2017 presentation
 
02 terms and issues
02 terms and issues02 terms and issues
02 terms and issues
 

Recently uploaded

Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Yara Milbes
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
abdulrafaychaudhry
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 

Recently uploaded (20)

Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 

Logs

  • 2. Objective • all activities that affect user state or balances are formally trackedAuditable • it’s possible to determine where an activity occurs in all tiers of the application Traceable • logs cannot be overwritten or tampered with by local or remote users High integrity
  • 3. Message Priorities/Levels • Severe errors that cause premature termination.fatal • Other runtime errors or unexpected conditions.error • are undesirable or unexpected, but not necessarily "wrong".Warn • Interesting runtime events (startup/shutdown).Info • detailed information on the flow through the system.Debug • more detailed information.Trace
  • 4. What to log? Log all the things Work Smarter, not Harder
  • 5. Default Message Priority/Level By default the message priority should be no lower than info. That is, by default debug message should not be seen in the logs.
  • 6. Default production log level WARNING
  • 7. Where to define logger layout? • private static Logger log = Logger.getLogger( MyClass.class ) – log.error() – log.warn() – log.info() – log.debug() • "%r [%t] %-5p %c - %m%n" – 176 [main] INFO org.foo.Bar - Located nearest gas station.
  • 8. What format to use? • A SINGLE LINE • Timestamps with timezone, to the millisecond or nanosecond • Class name + line number • Meaningful context
  • 9. Best practices for app • Do not allow exceptions to go unhandled/reach the browser • Display custom error pages to users with an email link for feedback • Do not enable “Robust Exception Information” in production. • Rotate log files to keep them current
  • 10. Use parameterized logging • LOG.debug("Method called with arg " + arg); • BAD: string varies with argument
  • 11. Use parameterized logging • if (LOG.isDebugEnabled()) { LOG.debug("Method called with arg {}", arg); • BAD: code clutter
  • 12. Use parameterized logging • LOG.debug("arg is {}", arg); • BAD: wrong level of language, this would be okay on TRACE
  • 13. Use parameterized logging • LOG.debug("Method called with arg {}", arg); • GOOD: string literal, no dynamic objects
  • 14. Exception example • catch (SomeException ex) { LOG.warn("Failed to do something with {}, continuing", arg, ex); } • GOOD: note how there is no "{}" for ex
  • 15. Provide useful event context • LOG.debug(arg.toString()); • VERY BAD: – no context provided – non-constant message string – assumes useful toString()
  • 16. Provide useful event context • LOG.debug("{}", arg); • VERY BAD – no context provided
  • 17. Provide useful event context • try { doSomething(arg); ... } catch (SomeException ex) { } • COMPLETELY BAD – silently ignoring errors!!!
  • 18. Provide useful event context • try { doSomething(arg);} catch (SomeException ex) { LOG.warn(ex.getMessage()); } • EXTREMELY BAD – message is not constant – no context is provided – ex.getCause() is lost – call stack is lost
  • 19. Provide useful event context • try { doSomething(arg); ... } catch (SomeException ex) { LOG.warn("Failed to do something with {}, ignoring it", arg, ex); } • GOOD – string literal – we explain what we tried to do – we pass along information we have about the failure – we explain that we recovered from the failure
  • 20. Provide useful event context • try { doSomething(arg); ... } catch (SomeException ex) { LOG.error("Failed to do something with {}", arg, ex); throw new RuntimeException("Failed to do something", ex); } • GOOD – string literal – we explain what we tried to do – we pass along information we have about the failure – we escalate the failure to our caller – we also 'chain' the exception so it is not lost and can be correlated
  • 21. Anything else? • Separate files for different areas of interest • Always Log To Local Disk

Editor's Notes

  1. It is important to ensure that log message are appropriate in content and severity. The following guidelines are suggested: fatal  Severe errors that cause premature termination. Expect these to be immediately visible on a status console. See also Internationalization. error  Other runtime errors or unexpected conditions. Expect these to be immediately visible on a status console. See also Internationalization. Warn Use of deprecated APIs, poor use of API, 'almost' errors, other runtime situations that are undesirable or unexpected, but not necessarily "wrong". Expect these to be immediately visible on a status console. See also Internationalization. Info Interesting runtime events (startup/shutdown). Expect these to be immediately visible on a console, so be conservative and keep to a minimum. See also Internationalization. Debug detailed information on the flow through the system. Expect these to be written to logs only. Trace more detailed information. Expect these to be written to logs only.
  2. Why timezone? Answer: maybe half our servers are in Toronto. If our sysadmins decide every computer should use GMT (or PST), great, but let's give the sysadmins the option! Timezone also helps around daylight-savings changes. Why nanosecond? Why not to the second? Answer: we want to minimize the number of lines occuring with identical timestamps. This is very important if you want to split logs into separate files covering different areas of interest (e.g. connection-history.log and messages.log). If your timestamps are to the nanosecond, you can re-merge these files together and usually not lose the order of events ("sort -m"). Personally, for Java I prefer to use "yyyy-MM-dd/HH:mm:ss.SSS/zzz". (I would use nanoseconds if Java supported it). High Volume Logging: It is probably impossible for any logging system to guarantee logs get written chronologically (in same order as the original events). In an extremely highly loaded system you will sometimes see out-of-order events in your log, usually by a few milliseconds. If you only log to the second, you cannot reestablish the chronology. Log analysis tools also need to be aware of this and not blowup when fed data that is not strictly chronological.