Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
Custom logger in Firestore to create statistics on operations?

How can I sniff all traffic in Firestore JS SDK?

To explain in more detail, the following code enables verbose logging into console.

import { setLogLevel } from 'firebase/firestore'
setLogLevel('debug')

Now, everytime a network communication happens, in the console there are outputs like:

[2022-09-28T12:00:21.878Z] @firebase/firestore: Firestore (9.6.10): Connection WebChannel received: {"documentChange":{"document":{"name":"projects/mu-project/databases/(default)/documents/my_collection/sHM7OvtpEygAKQBawxha","fields":{ ...

Is it possible to subscribe to such logs with a custom callback, instead of printing it in console, so I can analyze the communication?

Something like:

import { setLogLevel, setLogger } from 'firebase/firestore'
setLogLevel('debug')
setLogger((message, payload) => {
 // custom stuff
})

It is intended to create statistics on writes and reads, that are intended to be used on FE in realtime.

almost 4 years ago · Santiago Trujillo
2 answers
Answer question

0

It's possible in that you can build your own version of the SDK and make it do whatever you want. It's open source.

Otherwise, no, it's not possible.

You're probably better off instrumenting your own application code to make it capture the things it's doing with Firestore.

almost 4 years ago · Santiago Trujillo Report

0

I have found onLog function which can be used to register a callback on every produced log message. However, it does not solve the question precisely, because the function does not intercept the logging, and therefore, cannot mute the output to the console. It will produce a lot of debug messages which is not desired in the production deployment.

import { onLog, setLogLevel } from 'firebase/app'

setLogLevel('debug') // must be used to track the traffic
onLog((args) => {
  console.log('Custom log callback: ', args)
}, {level: 'debug'})

Also note that onLog must be called after the Firestore component is initialized.

almost 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!