Log to Console Only in Dev

You may want to use console.log to help you debug during development time, but you don't want those messages to appear to end users in production.

You've got several ways to accomplish this - you can strip out the lines as part of your build process, or you can overwrite the console.log function entirely, or you can try the technique here. In these examples, you can still use console.log when you specifically want to write to the console, even in production, but use a separate function, console.logVerbose, to output only in development, or when you've turned verbose logging on in the browser with a query string parameter.

View code on GitHub


Popular posts from this blog

C# Record Serialization

GZip in .NET

DotNet CLI