How to stop Firebase from logging status updates when app is launched
Asked Answered
A

11

116

Whenever I launch the FireBase app, it logs the status of various Firebase features. Right now this is what is being logged:

Configuring the default app.

<FIRAnalytics/INFO> Firebase Analytics v.3200000 started

<FIRAnalytics/INFO> To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see ...)

<FIRAnalytics/INFO> Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist

<FIRInstanceID/WARNING> FIRInstanceID AppDelegate proxy enabled, will swizzle app delegate remote notification handlers. To disable add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO

<FIRAnalytics/INFO> Firebase Analytics enabled

I looked through the pods and didn't find any print statements so how else would I go about stopping these from being logged overtime I run the app?

Authorization answered 18/5, 2016 at 22:25 Comment(3)
I agree with you. I'm also looking for a way to disable the messages.Amasa
Did you find a method?Gonfalonier
There should definitely be a case for turning messages off. It does not matter how many of them is logged. I don't mind getting warnings and errors, but the initial messages are distracting, no doubt about it.Discomposure
A
148

You can disable the debug logging with the flag -FIRDebugDisabled.

You can add it to your scheme:

  1. Select Scheme toolbar
  2. Edit Scheme
  3. Select Run
  4. Click Arguments and add -FIRDebugDisabled
Articular answered 18/5, 2016 at 22:49 Comment(4)
Ah I checked in with the engineers - those messages will be logged regardless. With the flag though, that's all you should see.Articular
A -noFIRAnalyticsDebugEnabled was renamed to -FIRDebugDisabled. Other steps are the same.Oversell
Not really good (this will likely not get added to code repositories etc and will thus cause different code depending on build method (think run/archive)). By default, release builds should have logs OFF... IMHO 😎Lightfoot
this has the awful side effect of turning of debug mode for firebase analyticsFourier
O
85

Add FirebaseConfiguration.shared.setLoggerLevel(.min) before FirebaseApp.configure() to achieve the minimum amount of logging.

func setupFirebase() {
  FirebaseConfiguration.shared.setLoggerLevel(.min)
  FirebaseApp.configure()
}
Ophthalmoscope answered 6/7, 2017 at 3:57 Comment(4)
This does the job!Rizika
Code has updated to FIRConfiguration.sharedInstance().setLoggerLevel(.min)Indiaindiaman
For anyone in objective-c: [[FIRConfiguration sharedInstance] setLoggerLevel:FIRLoggerLevelWarning]; [FIRApp configure];Muriel
I had to move FirebaseConfiguration.shared.setLoggerLevel(.min) AFTER FirebaseApp.configure() to work correctly.Misdemeanant
V
18

By default, Firebase will log info, errors, and warnings.
So u can set the logger level for which ever u need.
If you set for .Error you wil get min log only when error accours.

setLoggerLevel before FirebaseApp.configure() as shown below

In Swift 2.3 and Firebase 4

 FirebaseConfiguration.sharedInstance().setLoggerLevel(.Error)
 FirebaseApp.configure()

In Swift 3 and Firebase 4

 FirebaseConfiguration.shared.setLoggerLevel(.min)
 FirebaseApp.configure()
Vanitavanity answered 18/8, 2017 at 20:39 Comment(1)
How can I write this code in objective c can you please tell me thank youLongshore
F
17

In my case to hide the extra chunk of console log from Firebase I did the following:

  1. Navigate to Product -> Scheme -> Edit Scheme.
  2. Under Arguments tab in the Environment Variables section add OS_ACTIVITY_MODE = disable

enter image description here

  • Just in case you will need that, just simply uncheck the box.
  • Disabling OS_ACTIVITY_MODE sometimes will disable logs for all exceptions as well

Edit 1: As @jesus-adolfo-rodriguez said, this is related to Xcode. So, if you don’t want OSLog on the Xcode console, put OS_ACTIVITY_MODE Environment variable to “disable” in your scheme.


Edit 2:

FirebaseConfiguration.shared.setLoggerLevel(FirebaseLoggerLevel.min)
FirebaseApp.configure()

More details in the FIRConfiguration implementation here


Edit 3: 2019

According to this issue: https://github.com/firebase/firebase-ios-sdk/issues/2774#issuecomment-482780714

Adding -FIRDebugDisabled argument and cleaning the project did the trick.

The logging system in Firebase

The logging system has two modes: default mode and debug mode. In default mode, only logs with log level Notice, Warning and Error will be sent to device. In debug mode, all logs will be sent to device. The log levels that Firebase uses are consistent with the ASL log levels.

Enable debug mode by passing the -FIRDebugEnabled argument to the application. You can add this argument in the application’s Xcode scheme. When debug mode is enabled via -FIRDebugEnabled, further executions of the application will also be in debug mode. In order to return to default mode, you must explicitly disable the debug mode with the application argument -FIRDebugDisabled.

It is also possible to change the default logging level in code by calling setLoggerLevel: on the FIRConfiguration interface.

Fagen answered 25/9, 2017 at 22:43 Comment(5)
this has nothing to do with firebaseMoneymaking
and will hide your analytics if you want them to be shown -FIRAnalyticsDebugEnabledDipsomaniac
This disabled all the logs for me. As you said in the last point.Ultramundane
It helped me to reduce messages from Firebase which were logged notwithstanding setLoggerLevel(.min) and -FIRDebugDisabled. Great answer!Akerley
Stop telling people to disable all logging.Waxwing
B
8

Swift 4 Firebase 4.10

Set logger level in your AppDelegate.swift

FirebaseConfiguration().setLoggerLevel(FirebaseLoggerLevel.min)

Here is full code:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    FirebaseConfiguration().setLoggerLevel(FirebaseLoggerLevel.min)
    FirebaseApp.configure()
    return true
}
Bemba answered 8/3, 2018 at 13:40 Comment(1)
As of Oct 2020, this is the only answer that got rid of the Firebase logs, but left my own logging alone. Helps for analyzing what's happening on startup of your app.Horseshoe
W
7
FIRConfiguration.sharedInstance().setLoggerLevel(.min)
FIRApp.configure()

In Swift 4

Widthwise answered 7/5, 2018 at 16:32 Comment(1)
FirebaseConfiguration.shared.setLoggerLevel(.min) in FB 5.14Tsunami
C
4

By default Firebase Analytics will only log 4 INFO lines in production + errors/warnings. That should be very little output if things work correctly. Adding -noFIRAnalyticsDebugEnabled will only disable DEBUG level logs and ERROR/WARN are always logged. If you see any warnings or errors you probably need to do something to resolve the cause. Some things will likely not work correctly if warnings/errors are logged. App that is correctly setup should not log errors/warnings.

Messages tagged with FIRInstanceID/* are logged by Firebase Notification and errors/warnings are always logged.

Cataphyll answered 23/5, 2016 at 18:23 Comment(0)
I
4

I think there is a big and a very important confusion going on.

By using -FIRDebugDisabled it will disable debug mode which then your measurements will be affected during testing and development.

Currently there is no way to enable debug mode and disable logs at the same time. So the FirebaseConfiguration.shared.setLoggerLevel(.min) will work basically on not debug mode only.

As workaround you can use -noFIRAnalyticsDebugEnabled which is only for Xcode console logging, this one does not disable your debug mode.

Implausible answered 31/3, 2020 at 4:58 Comment(0)
W
3

As djabi said, you cannot disable those logs if they are INFO, WARNING or ERROR.

I want to add to Nitin Gohel's answer since I can't comment: The flag FirebaseAppDelegateProxyEnabled is not for disabling logs. If you turn it off, you will lose the auto campaign tracking and you will need to add the methods from FIRAnalytics(AppDelegate) to handle URL and user activity yourself.

Weight answered 31/5, 2016 at 15:28 Comment(0)
I
3

To add to Alex' answer, from https://firebase.google.com/docs/cloud-messaging/ios/client

FirebaseAppDelegateProxyEnabled is for swizzling your app delegate 's methods

The FCM API performs method swizzling in two key areas: mapping your APNs token to the FCM registration token and capturing analytics data during downstream message callback handling. Developers who prefer not to use swizzling can disable it by adding the flag FirebaseAppDelegateProxyEnabled in the app’s Info.plist file and setting it to NO (boolean value). Relevant areas of the guides provide code examples, both with and without method swizzling enabled.

Imes answered 17/1, 2017 at 13:21 Comment(0)
T
2

If you want the clean and necessary logs in console, just set your scheme like this. Open the "Edit Scheme" and select "Arguments".

  • -FIRAnalyticsDebugEnabled (don't forget "-")
  • OS_ACTIVITY_MODE = disable

enter image description here

Torbernite answered 16/2, 2022 at 7:8 Comment(1)
I would not recommend this. OS_ACTIVITY_LOG = disable will kill Apple's universal logging which means that any logging you do want will also disappear.Inefficient

© 2022 - 2025 — McMap. All rights reserved.