grpc / grpc/grpc-java

Solve logging

Aperta
#1,577 32 commenti 8 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
12.1k
Fork
4k
Merge medio
2g 17h
PR unite (30g)
37

Descrizione

We used to have some INFO logs, but they were considered spam by some users (#1439), so they were reduced to FINE (#1449). In general, open source libraries don't log unless something is going wrong, and these log statements didn't imply something was wrong.

However, in #1538 INFO-level logs were added back (in a different place, but same effective event). These could be a lower level, but it seems difficult for users to enable a higher logging level.

We do know applications can do something like this to squelch what is logged:

``` java
// May need to save this reference
Logger log = Logger.getlogger("io.grpc");
log.setLevel(Level.WARNING);
```

More than one project has been annoyed with the logging-by-default, but the number of Java developers who can handle logging.properties seems limited.

On Android, things are even worse because most phones almost always return `false` from `Log.isLoggable()` for lower log levels. Developer phones (like debug builds of Android) will return true, but few develop on such phones. This means that even when you configure java.util.logging to log lower levels, they won't actually be logged. You can run a command like `adb shell setprop log.tag. VERBOSE` for _each class_ you want to log, where the `MAGICTAG` can be found from `DalvikLogging.loggerNameToTag()`, but this is so painful it isn't close to practical.

Note that most Android applications don't notice any problem with `Log.isLoggable()` because while it may return `false`, if you call the log anyway (say, via `Log.v()`) apparently it will be logged.

One developer suggested we use `slf4j` because it is "java best practices." I think in some part of the Java world it is, but it is unclear whether grpc exists in that part of the world. The number of developers that can configure java.util.logging, log4j, logback, or slf4j is certainly higher than just java.util.logging, but it will also become harder to direct users in how to enable logging when we need it for a report. It also has the deficiency that "If no binding is found on the class path, then SLF4J will default to a no-operation implementation" which is pretty bad for our WARNING statements.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia esaminando le issue #1439, #1449 e #1538 per comprendere le modifiche precedenti al logging e gli eventi effettivamente coinvolti. Confronta la configurazione di java.util.logging discussa qui con il comportamento di Log.isLoggable() di Android e con l’alternativa slf4j proposta. La issue non definisce un approccio selezionato né una condizione di completamento chiara.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
observability
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.