Why are some informational log messages printed but not others in release build?

I’ve been looking through the realtime logs of an iOS release build of my Unity mobile game (i.e., the build did not have “Development Build” checked). I couldn’t find the log message that I was looking for, even though that code path was definitely executing. It occurred to me that Unity might be stripping informational logs from release builds (i.e., with LogType.Log), or else conditionally not printing them. However, I am seeing other informational logs, and it seems entirely inconsistent. Regardless of assembly or type, some log messages are showing up in the iOS realtime logs, while others are not. In fact, some informational logs are printing, while some Warning messages or not, so there doesn’t seem to be any LogType-based filtering happening.

Has anyone else observed this behavior? I’m okay with informational logs not printing in release builds for performance reasons, but why are some printing and others not, seemingly at random? And how would informational logs print but not warnings? Is there like a log throttling mechanism within release builds?

It’s an interesting question. I’ve seen the behavior change over the years of using Unity so I’m not sure where it stands. Perhaps what is shown is dependent not only on log level (notice, warning, error), but also subsystem, eg., from your scripts versus something in the engine core?

I have been on many projects that aggressively wrap Debug.Log() with their own system so they can be confident that all of their script logging is disabled in release builds. It has never materially improved the project, because invariably when there is a crash in release, it just keeps you from seeing what happened easily, dragging out the debugging time.

I consider such coding to be naively-ham-fisted over-engineering. The bulk of the benefit could come from just removing per-frame logging and leave in the init / deinit logging, which is often where our scripts choke up anyway. It’s not as bad as pokemon try/catch exception handling, which is its own special misery if you ever have to deal with it in a project!

ALSO: the editor wraps a bunch of stuff and throws different errors, such as Missing Reference and Unassigned Reference errors, which most of the time blow up as a Null Reference Exception in a non-editor actual build.

Thanks for responding, @Kurt-Dekker.

Yeah I very consciously did not want to implement my own logging system lol. I’m essentially using Serilog, with a custom Unity sink. I set Serilog’s LoggerConfiguration.MinimumLevel to the equivalent of Unity’s Debug.unityLogger.filterLogType.

I agree with all your best practice thoughts. I don’t use any per-frame logging and I try to stick with event-based logs (“Starting operation X” and “Operation X completed” type stuff), and I always leave Informational logs and above enabled to help with debugging. I use Unity Analytics and they actually show the most recent logs alongside analytics events, which can be helpful. I do try to follow .NET’s high-performance logging setups wherever possible though, to eek out a little extra performance by not parsing log messages during every call, e.g.

I had that thought, but the logs are inconsistent even among my scripts. In one case, I have a Bootstrapper class that runs at app startup, logging a bunch of times as it sets up various systems, but only one of these messages is printing, even though all the others are being logged the same way. :face_with_spiral_eyes:

Interesting. I don’t think that’s relevant to this logs-sometimes-being-printed issue, but good to know. :+1:

Also I’ve never heard “pokemon exception handling” lol; I love that. “Gotta catch em all” :sweat_smile:

FWIW this seems a recurring problem but only on mobile. I guess the idea here is to keep things responsive in case an application logs too aggressively. Perhaps it may also have to do with thread congestion, especially if you view live logs transferred from the device and shown to you (ie in Xcode). Did you search through the actual log file or some log viewer?

In release builds there may also be stripping happening, but only if the log is in a method flagged with the [Conditional] attribute.

Haven’t heard of this before. But makes total sense: “Gotta catch 'em all!” :smiley:

I suppose this refers to catch-all exception handling and possibly not even logging it.

It does indeed! I actually read that pokemon term somewhere on these forums… so applicable.

I’ll flag this for spam, not because of you but because this website seems potentially harmful. There’s no legally identifiable information to be found ie nobody knows who that company or individual is. It’s also pretty much a violation of law around the globe if their tools are sold internationally.

Perhaps use a tool suited for the job? Xcode should show you live logs, and then there’s ADB and even though that’s a command prompt tool, I’m betting there exists some form of UI for it if only to show the live logs.

@CodeSmile That seems excessive. 3uTools is a pretty well-known tool; I’ve come across numerous forums/articles/tutorials about it, and the application feels quite solid and well-designed. I agree it’s sus that there’s no company name on the website and their About Us page lists a Gmail email, but the application itself has an About screen with the company name “Shenzhen Aidapu Network Technology Co.,Ltd.” and a full EULA and Privacy Policy. They’re a Chinese company so maybe that’s why their website is a little atypical; idk. All in all I’ve had no issues with 3uTools over the last year, and I see no reason to consider it or its website harmful (other than the general twitchiness that a Westerner might get when hearing that an application is Chinese).

I do use ADB for Android (with Unity’s Android Logcat package) but Xcode requires a Mac, which I do not have. Once upon a time, I googled “view ios logs on windows” and 3uTools was the first tool that came up.

It’s just good marketing. Most of those articles could as well have been engineered, reviews mass generated. Many niche tools gained fame this way.

The dead give-aways that this is not a legit company is the About Us and Legal Statement and Disclaimer pages. None mention the company’s name, registration, address, or any other legally required forms for companies doing business internationally - even according to chinese law!

I would not entrust this company with any personal information, let alone payment details! This is unlikely to be a legit operation.

Actually, it’s much more concerning since this could be more than “just” consumer scam. It’s actually targeting application developers which means the tool would typically run with elevated privileges and may be sending who knows what back to China, including developer private keys or entire source repositories. And for the company to operate without a legal footprint it may even be state owned and operated as a deliberate cyber espionage operation.

With actual beneficial functionality it’s the perfect trojan horse! I would not trust this software one single bit!

I mean yes, I’m aware that that kind of thing happens, but I’m talking about trustpilot reviews written in plain English (discussing particulars of the software and not just mass-generated “this program is so great 5/5”-type messages), Reddit posts plainly discussing whether it’s reliable (which I wouldn’t expect engineered comments to do, with several comments about how the only people really against it are those put off by Chinese software in general), YouTube guides by humans discussing how to use the tool, etc. Could all of those be faked? Sure, I guess, depends how deep you think the conspiracy goes. But if 3uTools has gained fame for being useful than that’s not nothing IMO.

To be fair, I did come across this Reddit post claiming that 3uTools is malware, but they were mostly talking about the questionable legality of using their jailbroken IPA files, which I am not. I don’t mess with jailbreaking in general, but 3uTools is hardly the only tool in that space. Something tells me you wouldn’t fear a similar tool made by an American/European company to this extent.

Indeed, like I said in my last message, I also find this odd, as well as the Gmail email address. But I also mentioned that the company has Terms of Use and Privacy Policy within the app, and these do provide the company name, address, and contact info, so it’s not like the information is hidden.

Good thing it doesn’t require payment or creating an account to use. :ok_hand:

This is the kind of blind fear of Chinese software that I was talking about. This random dev tool isn’t going to steal your soul any more than Facebook or Snapchat already does (or Unity, for that matter). Even if the tool is collecting every single log message that I pass through it, I can’t overstate how un-concerned I am about the Chinese government knowing what my little mobile card game logs. It’s not that important. If I were logging PII or payment details in plaintext or something then maybe I’d feel differently, but that would be on me for logging that stuff anyway. That said, the tool does run elevated, so sure, maybe it’s uploading my entire hard-drive to China and running a crypto mining program for Xi Jinping while watching my children sleep. I haven’t reverse-engineered it so I have no proof that it doesn’t, but neither do you have proof that it does. :man_shrugging:

Anyway, this Discussion is derailing a bit from my original questions about logging. If anyone else (particularly a Unity dev) has insight on how production logs are filtered (on iOS), I would much appreciate it. :folded_hands:

Not unless they also omit the legally required company details on their website. :wink:

Sure. You needn’t worry. But I would be a horse it won’t be used internally by Ubisoft, EA, Bethesda, etc.

It could also become a problem. You don’t worry now. The tool becomes a natural thing to use. Then you get that nice freelance job for (insert high profile industry customer). That’s when it will be a problem.

Hence why it’s best to err on the safe side. :wink:

In any case, and to be on topic: since you use a 3rd party tool, consider that the tool itself may be the problem. Check if these log statements do appear in the actual log file on the device. I think I mentioned this before, or perhaps we already resolved this not to be the problem. But in case we didn’t that’s the thing to verify.

Probably not. Those companies probably just provide Macs for their developers who need them. Having worked for some large companies (not gamedev studios, but still), getting a random tool from the internet approved/installed is always a slow and annoying process, unless they give devs local admin privileges. You’re probably right that the sketchy legal docs on 3uTools’ website would give them pause.

In general, I agree with erring on the safe side. I don’t wanna give the impression that I do zero vetting of software before installing it, or discourage anyone else from being careful. 3uTools has enough sketchiness that I can understand your or anyone else distrusting it; I’ve found it useful and polished enough that I do trust it. :man_shrugging: Maybe my standards are just lower lol. I mainly wanted to clarify that “it’s Chinese” is not a real reason not to use a piece of software IMO.

The real villain here is Apple for not having official Windows tools for iOS developers. :roll_eyes:

Fair point. My issue was trying to do all this on Windows where Apple has forced us to use 3rd party tools…but I guess I should just find a Mac to borrow and get device logs in an actual Xcode instance. I sense that the logs will be the same there and I’ll still be in the dark, but it’s worth a try.