WebGL logging to browser console

Hi!
Does anyone know how to disable these logs? (I mean browser’s JS-logs)
In the settings of Player Settings/Other Settings/Logging I set all the checkboxes to None. But there is no effect - the console still full of errors and messages.
How to disable all theese messages?

See this old thread with suggestions on how to override the logging methods to do what you want:

Hopefully you’ll find a solution to what you want there.

I think my problem is almost the reverse of yours - not show exception, but hide them :wink:
And what are these Logging’s checkboxes means?

i meant - the techniques shown in that forum thread show how to override the default logging methods. once you override them, you can probably add empty implementations (so you get no logging at all).

I’ve never tried it, but i suppose it could work.

Disable Debug.Log(…). you can try (maybe same of Player Settings)

Debug.logger.logEnabled = false;

and you can redefine javascript console function.

Application.ExternalEval("console.log = function(){}");
Application.ExternalEval("console.warn = function(){}");
3 Likes

Interesting thank you!

It does write all logging information (such as Debug.Log, Console.WriteLine or Unity’s internal logging) to the browser’s JavaScript console. Documentation.

Resurrecting this thread too. Using 2018.4.27f1. Would expect that Logging set to NONE in the publish settings would output WebGL that does not send Debug.Log() to the browser’s console

Instead of rewriting console.log and console.error, which will prevent logging from all other sources on the web site, you can try rewriting unityInstance.Module.print and unityInstance.Module.printErr to drop Unity specific logging. Does that help?

1 Like

Hello. Can you tell me how to do this correctly?

Unfortunately not: I just tried it and the print/printErr method is not called.

var gameInstance = UnityLoader.instantiate(....);
gameInstance.Module.print = function(){};
gameInstance.Module.printErr = function(){};

If I add a breakpoint in the UnityLoader.js where the print and printErr methods are defined, they aren’t called as well.

Resurrecting this thread, any chance anybody has an update on this @jukka_j ?? gameInstance.Module.print is not defined by the instance.

1 Like

I, too, would like a more tenable solution than disabling console logging for the entire web app. There are many things in the web app I would want to have logged to the console, just not the enormous amount of pretty useless information logged by Unity.