neteinstein
neteinstein

Reputation: 17613

Android: java.util.logging.Logger vs android.util.Log

Why does Android maintain 2 different Log classes that seem to support the same things?

I'm talking about:

  1. Log android.util.Log
  2. Logger java.util.logging.Logger

For what I've seen for some years developing, every Android official documentation points to the Log and not the Logger.

Even specific loggers like the TimingLogger uses the Log.


So why are those 2 supported?

Are there any feature that can be used through Logger than I can't achieve through Log?

Are there specific use cases for both?

Upvotes: 7

Views: 1633

Answers (1)

jmehrens
jmehrens

Reputation: 11045

The feature crossover seems to be:

  1. android.util.Log = java.util.logging.Logger
  2. android.util.Printer = java.util.logging.Formatter
  3. android.util.PrintStreamPrinter = java.util.logging.StreamHandler

Seems like "android.util.Log" is going to have:

  1. Support for android log.
  2. Support for out to Streams, Writers, and Strings.
  3. Is going to be a smaller, lightweight, and probably faster.

Looks like "J.U.L" is going to have:

  1. Buffering of records with the java.util.logging.MemoryHandler. This is good for say when a SEVERE error occurs you can include the last 1000 records which may be at lower level.
  2. Filtering of records using java.util.logging.Filter. There are no out of box filters included but it does give more granularity over implementing this behavior in a android.util.Printer
  3. Out of box support for XML.
  4. Out of box support for Sockets.
  5. Support for 3rd party java.util.logging.Handler implementations.

Upvotes: 3

Related Questions