简体   繁体   中英

how to prevent browser from writing log in the console?

I am creating a simple chat app using SignalR. But the problem is if I open the console on my browser, I can see which port it is connected to, message transmission information and other logs. I want to prevent browsers from writing these information. How can I do this?

[Example: WhatsApp. We can't see anything if we open the console while browsing WhatsApp's web portal.]

You can redefine window.console :

window.console = {
    log: ()=>{}, info: ()=>{}, error: ()=>{}, warn: ()=>{}//etc
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM