Struggling to write response to a file

Still new to a k6.
Struggling to write response to a file .
Running following code

import http from "k6/http";
import { check } from "k6";
import { parseHTML } from 'k6/html';

export const options = {   vus: 1,  iterations: 1,  httpDebug: 'full',  }

  export default function () {
    let the_url;
    the_url = '';

export function getResponse(the_url){
  const res = http.get(the_url);
  const doc = parseHTML(res.body); // equivalent to res.html()
  console.log('\tDBG: '+  doc);

outputting the response to a file k6 run ./_eg-.js 2>./logs/resp.html
i need to see the HTML file
getting large html file

6 : time="2022-11-30T22:20:35-05:00" level=info msg="Request:
GET / HTTP/1.1
User-Agent: k6/0.41.0 (
Accept-Encoding: gzip

" group= iter=0 request_id=c65a8c1a-fee7-4c89-573d-35540e8592f0 scenario=default source=http-debug vu=1 At line:1 char:1 + k6 run ./_eg-.js 2>./logs/resp.html + + CategoryInfo : NotSpecified: (time="2022-11-3...http-debug vu=1:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError time="2022-11-30T22:20:35-05:00" level=info msg="Response:
HTTP/2.0 200 OK
Content-Length: 498970
Age: 200900
Cache-Control: public, max-age=0, must-revalidate
Content-Type: text/html
Date: Mon, 28 Nov 2022 19:32:15 GMT
Etag: \"6734b9991402efbc87193ec834b1109d\"
Last-Modified: Mon, 28 Nov 2022 17:36:48 GMT
Server: AmazonS3
Vary: Accept-Encoding
Via: 1.1 (CloudFront)
X-Amz-Cf-Id: MS4A7Rh1MDrbb90KgM29vVgJHfPV6tfWPTZ47Pkj0OchdPzAt0QHIA==
X-Amz-Cf-Pop: YTO50-P2
X-Cache: Hit from cloudfront

What do i do wrong

Hello! I can’t help yet, I’m afraid, but do you mind clarifying a few things about your use case?

  • What primary goal here? What would you do with this file?
  • Does console.log('\tDBG: '+ doc) log what you want? Maybe you could use the --log-output option to write this to a file.
  • For more complex writes, you might need to use an extension, for the reasons explained in this post Write data to file - #2 by imiric

i need it for debugging
When i am doing console.log('\tDBG: '+ doc), the result is to big.
see the attached sample.