Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: log4js.getLogger is not a function #1410

Open
TheChilliPL opened this issue Jan 4, 2024 · 2 comments
Open

TypeError: log4js.getLogger is not a function #1410

TheChilliPL opened this issue Jan 4, 2024 · 2 comments

Comments

@TheChilliPL
Copy link

Trying to use anything in log4js causes a TypeError. IDE sees all the methods correctly, but TypeScript itself does not.

D:\Projects\eng_to_ipa>npm start -- trans

> eng-to-ipa@0.1.0 start
> npx tsx src/cli.ts trans

D:\Projects\eng_to_ipa\src\main.ts:3
export let defaultLogger = log4js.getLogger();
                                  ^


TypeError: log4js.getLogger is not a function
    at <anonymous> (D:\Projects\eng_to_ipa\src\main.ts:3:35)
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async loadESM (node:internal/process/esm_loader:28:7)
    at async handleMainPromise (node:internal/modules/run_main:120:12)

Node.js v21.5.0

D:\Projects\eng_to_ipa>

Importing with import { getLogger } from "log4js" doesn't work either

@lamweili
Copy link
Contributor

lamweili commented Jan 4, 2024

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)

@TheChilliPL
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants