12

How to set log level for Firestore?

According to documentation here, i should use setLogLevel method but i can't see method at Firestore client objects, like FirestoreClient.getFirestore().

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
MiguelSlv
  • 14,067
  • 15
  • 102
  • 169

5 Answers5

12

For those who ended up here trying to change the log level for the JS Web SDK:

firebase.firestore.setLogLevel("debug");    // "debug" | "error" | "silent"

Notice the lack of () after firestore, as opposed to:

firebase.firestore().settings(/*...*/)
TheMechanic
  • 820
  • 1
  • 8
  • 23
  • 1
    for v9 its: import {setLogLevel} from "firebase/firestore"; setLogLevel("debug"); https://firebase.google.com/docs/reference/js/firestore_.md#setloglevel – chrismarx Sep 26 '22 at 16:41
8

Current versions for most environments documented in this gist.

JavaScript

// https://firebase.google.com/docs/reference/js/firebase.firestore.Firestore#setLogLevel
firebase.firestore.setLogLevel('debug');

Node.js

// https://firebase.google.com/docs/reference/js/firebase.firestore.Firestore#setLogLevel
firebase.firestore.setLogLevel('debug');

Android

// See https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/FirebaseFirestore.html#setLoggingEnabled(boolean)
FirebaseFirestore.setLoggingEnabled(true);

Swift

// https://firebase.google.com/docs/reference/swift/firebasefirestore/api/reference/Classes/Firestore#enablelogging_
Firestore.enableLogging(true)

Java Admin SDK

Uses SLF4J (Java's built-in façade logger) as described in Hiranya's blog post.

1) Add the slf4j-simple binding to the application classpath 2) Set the -Dorg.slf4j.simpleLogger.defaultLogLevel=debug system property

GCP environments

# See https://medium.com/@hiranya911/logging-in-java-libraries-for-firebase-and-google-cloud-platform-f8742493b73f

.level=INFO
com.google.firebase.level=FINE
java.util.logging.SimpleFormatter.format='%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS %4$s %2$s %5$s%6$s%n'
Kato
  • 40,352
  • 6
  • 119
  • 149
1

For firebase-firestore:21.1.1 use this line:

FirebaseFirestore.setLoggingEnabled(true);

Further Reference

Darush
  • 11,403
  • 9
  • 62
  • 60
0

There is currently no logging functionality in the Java Server SDK for Firestore. Firestore supports logging in all the Mobile clients (Android, iOS and Web) as well as in the Node Server SDK.

  • when i run i get lots of lines like this `2018-02-08 00:16:46,098 DEBUG [grpc-default-worker-ELG-2-3] (io.netty.util.internal.logging.Slf4JLogger:86) - [id: 0x1f4aec1c, L:/192.168.1.70:50470 - R:firestore.googleapis.com/216.58.211.202:443] OUTBOUND SETTINGS: ack=false settings={ENABLE_PUSH=0, MAX_CONCURRENT_STREAMS=0, INITIAL_WINDOW_SIZE=1048576, MAX_HEADER_LIST_SIZE=8192}` – MiguelSlv Feb 08 '18 at 00:18
  • These are low-level gRPC logs. How did you manage to enable them? If this just happened, chances are you have a `logging.properties` file installed in your environment. You will have to find that, and update it accordingly. – Hiranya Jayathilaka Feb 08 '18 at 00:23
  • I am not sure. I am using log4j logger. The io.netty.util is set to ´OFF´ at log4j.xml config file but i am still getting this, so i was trying to set it off in code. – MiguelSlv Feb 08 '18 at 10:53
  • Well the above entry is logged in the `DEBUG` level. So clearly something in you environment has enabled `DEBUG` level logs. Usually you don't get any logs when you run Firestore clients. – Hiranya Jayathilaka Feb 08 '18 at 19:46
  • You can enable Java server-side logging by following [Hiranya's blog post](https://medium.com/@hiranya911/logging-in-java-libraries-for-firebase-and-google-cloud-platform-f8742493b73f) – Kato May 29 '18 at 17:52
-2

For Angular-CLI, Add this to your app.module.ts file:

import * as firebase from 'firebase/app';
import 'firebase/firestore';
firebase.firestore.setLogLevel('debug');

reference

Elron
  • 1,235
  • 1
  • 13
  • 26