NeTTN
Denoβ€’3y ago
NeTT

How do I use std/log?

I'm trying to create a log file. I don't seem to be able to make it work tho.

import { handlers, Logger } from "https://deno.land/std@0.175.0/log/mod.ts";

const file_reg = new handlers.FileHandler("INFO", {
  filename: "./reg_log",
  formatter: "{levelName} {msg}",
});

file_reg.setup();
const logger = new Logger("registration", "INFO", {
  handlers: [file_reg],
});
// Log file is created at this point

logger.info("aaa")
// This part is not written to the file
Was this page helpful?