How can I use console logging in Internet Explorer?

ground5hark picture ground5hark · Apr 17, 2010 · Viewed 194k times · Source

Is there a console logger for IE? I'm trying to log a bunch of tests/assertions to the console but I can't do this in IE.

Answer

Craig picture Craig · Apr 17, 2010

You can access IE8 script console by launching the "Developer Tools" (F12). Click the "Script" tab, then click "Console" on the right.

From within your JavaScript code, you can do any of the following:

<script type="text/javascript">
    console.log('some msg');
    console.info('information');
    console.warn('some warning');
    console.error('some error');
    console.assert(false, 'YOU FAIL');
</script>

Also, you can clear the Console by calling console.clear().

NOTE: It appears you must launch the Developer Tools first then refresh your page for this to work.