Open TheChilliPL opened 10 months ago
What's your import statement?
Could you show what's in your main.ts
?
Did you try this?
import * as log4js from "log4js";
log4js.configure({
appenders: { cheese: { type: "file", filename: "cheese.log" } },
categories: { default: { appenders: ["cheese"], level: "error" } },
});
const logger = log4js.getLogger();
logger.level = "debug";
logger.debug("Some debug messages");
(src: https://github.com/log4js-node/log4js-node?tab=readme-ov-file#typescript)
The whole main.ts
is just
import * as log4js from "log4js";
export let defaultLogger = log4js.getLogger();
If I do configure
first, it just does
TypeError: log4js.configure is not a function
@TheChilliPL @lamweili What was the resolution here? I'm running into the same issue, I think.
@relandboyle Never fixed it, just never started using this logger, because I don't have the time necessary to debug this issue. If you find a way to fix it, however, please do let know!
import log4js from "log4js";
const logger = log4js.getLogger();
logger.level = "debug";
Now I was able to do it. Hope this is useful.
import log4js from "log4js"; const logger = log4js.getLogger(); logger.level = "debug";
Now I was able to do it. Hope this is useful.
This is the correct way to import. The documentation really needs to be updated. Just lost a lot of time trying to understand why I was getting the "log4js.[blank] is not a function" errors.
Trying to use anything in
log4js
causes a TypeError. IDE sees all the methods correctly, but TypeScript itself does not.Importing with
import { getLogger } from "log4js"
doesn't work either