Diagnostic Flashcards

1
Q

Logging

A

automatically recording diagnostic output from a program

logging output can be useful during development and testing, but also in production code. A web server could log IP address of incoming http requests. A mail server could log basic info about each email recieved

Logging using standard error output, or ordinary file output, can be done

It can be better to make use of a logging framework, which provides lots of useful functionality

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Logging Framework or API (application programmer inferface)

A
  • specificies origin of log entry (which application, which class, which method…)
  • specify content of log entry
  • specify level of importance of log entry
  • control what importance levels are actually being logged
  • control where log entries are recorded
  • analyze resulting log files
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Classes in java.util.logging

A

important classes of java.util.logging package:

  • Logger
  • Handler (subclasses - consoleHandler, FileHandler, SocketHandler)
  • Formatter (subclasses- simlpeformater, XML formatter)
  • Level
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Level class (java.util.logging.Level)

A

contains public static names constants used to specify the importance level of log messages, and to control which log records are actually logged

(from high to low):
Level.SEVERE
Level.WARNING
Level.INFO
Level.CONFIG
Level.FINE
Level.FINER
Level.FINEST
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Levels are used in two (2) ways

A

when logging a message a level must be specified for that message

each logger and handler has a level set for it; log messages with a level less than that are ignored

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Other named constants

A

Level.ALL

Level.OFF

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Handler

A

Handles the log message

Each logger object must have one or more handler object associated with it, to actually log any log messagges

Existing Handler Classes:

  • ConsoleHandler: log to stderr, Each logger has this handler by default
  • FileHandler: log to a file, with controllable log file rotation
  • SocketHandler: connect to a logging server over a TCP/IP socket
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Formater

A

Each Handler object must have a formatter object which it uses to format logging messages

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Existing Formatter Classes

A

SimpleFormatter: the default for ConsoleHandler

XMLFOrmatter: the default FileHandler and SocketFormater

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Each log message has an associated log Level. The Level specifies the importance and urgency of a log message. Levels are really integers, with higher values indicating higher priorities.

A

The Level class defines seven standard log levels as named constants, ranging from FINEST (the lowest priority, with the lowest value) to SEVERE (the highest priority, with the highest value).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

The Level class defines a set of standard logging levels that can be used to control logging output. The logging Level objects are ordered and are specified by ordered integers. Enabling logging at a given level also enables logging at all higher levels.

A

The levels in descending order are:

SEVERE (highest value)
WARNING
INFO
CONFIG
FINE
FINER
FINEST (lowest value)
In addition there is a level OFF that can be used to turn off logging, and a level ALL that can be used to enable logging of all messages.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Lab9: Question 2: What level would I use to turn off logging? What level would I use to enable the logging of all messages? (The Level class link used for Question 1 might be useful)

A

In addition there is a level OFF that can be used to turn off logging, and a level ALL that can be used to enable logging of all messages.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Tracing involves logging messages which report the state of the application at different stages of execution. In the Java logging framework, there are three levels that should be used for tracing:

A

FINE, FINER and FINEST.

FINE: Use this level for significant events that explain the flow or state of the system when trying to understand or debug a problem. These are usually at the level of object creation, catch clauses for exceptions that do not constitute errors, and so on.

FINER: There is a set of Logger methods that generate messages with a FINER level. These are entry(…), exit(..), finer(..) (This is a method named finer; different from a logging level called FINER) and throwing(..). Entering and exiting should be used for tracing method entry and exit; arguments and return values can be specified. Finer can be used for any tracing that is more verbose than desired for fine, but is not method entry/exit or used before throwing an exception. Throwing should be used when you are about to throw or re-throw an exception.

FINEST: Finest is usually thought of as developer or debug tracing. This is used during development, when attempting to learn the behavior of a system at a fine level of detail and when trying to diagnose difficult problems once the code is released. This level of tracing can be used to track the state of instance variables in a class e.g. before a method call, inside a method or a loop and after a method call.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly