#How to redirect cconsole.log's output to a file

5 messages · Page 1 of 1 (latest)

quiet kestrel
#

How to redirect cconsole.log's output to a file
I want to run the js code with rust and get the data from consloe.log()
Most of the code is the same as in the runtime/examples https://github.com/denoland/deno/tree/main/runtime/examples
A little bit different

let file=File::open("log.txt").await?;
 let stdio=Stdio {
     stdin: StdioPipe::Inherit,
     stdout: StdioPipe::File(file),
     stderr: StdioPipe::Inherit,
 }
let options = WorkerOptions {
//...
   stdio: stdio,
 };

I noticed that the code has

let permissions = PermissionsContainer::allow_all();

Granted read access to the file

The error message looks like this

Error: PermissionDenied: Access Denied。 (os error 5)
    at Object.print (internal:core/01_core.js:394:32)
    at Console.<anonymous> (internal:deno_runtime-0.97.0/js/98_global_scope.js:126:40)
    at console.log (internal:ext/console/02_console.js:1984:22)
    at file:///D:/deno_run/examples/hello_runtime.js:1:9
error: process didn't exit successfully: `target\debug\deno_run.exe` (exit code: 1)

Anyone tell me what's going on, thanks guys

GitHub

A modern runtime for JavaScript and TypeScript. Contribute to denoland/deno development by creating an account on GitHub.

quiet kestrel
#

How to redirect cconsole.log's output to a file

#

Can anyone tell me what to do? I just want to get the information that js is outputting using consoleplayful_deno

quiet kestrel
#

I still haven't solved the problem, samurai_deno

crisp raft
#

I think it might have something to do with your folder permission settings. Maybe the file is being saved to a different folder than you expect

IDK if you really need to do this at code level, but you can pipe stdout to a file at OS level via CLI by calling your program with a command like deno run app.ts > app.log or something