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

multiFile type is not able to use with the error: type "multiFile" could not be found #1395

Open
nabe1653 opened this issue Sep 22, 2023 · 5 comments · May be fixed by #1423
Open

multiFile type is not able to use with the error: type "multiFile" could not be found #1395

nabe1653 opened this issue Sep 22, 2023 · 5 comments · May be fixed by #1423

Comments

@nabe1653
Copy link

I uses log4js v6.9.1 in TypeScript project with esbuild.
Already I'm using console and dateFile type logging there.

And I tried to use multiFile type then logger shows below error.

Error: Problem with log4js configuration: ({
  appenders: {
    batchLog: {
      type: 'multiFile',
      base: 'logs/',
      property: 'categoryName',
      extension: '.log'
    }
  },
  categories: { batchLog: { appenders: [ 'batchLog' ], level: 'debug' } }
}) - appender "batchLog" is not valid (type "multiFile" could not be found)

I tried to copy some appenders from other issues so maybe config itself is not missed.
How can I use multiFile option?

@Xalaphs
Copy link

Xalaphs commented Nov 29, 2023

Same issue here, did you find a solution ?

@nabe1653
Copy link
Author

No, I gave up to use this log-type at that time.

But still using this lib for other log-type so I'm waiting answer too.

@lamweili
Copy link
Contributor

lamweili commented Dec 11, 2023

Can you provide a sample index.js with your log4js configuration so that I can replicate it?

I created a typescript.zip project which works fine.

Code:

import * as log4js from "log4js";
log4js.configure({
  appenders: {
    cheese: { type: "file", filename: "cheese.log" },
    batchLog: {
      type: 'multiFile',
      base: 'logs/',
      property: 'categoryName',
      extension: '.log'
    }
  },
  categories: { 
    default: { appenders: ["cheese"], level: "error" },
    batchLog: { appenders: [ 'batchLog' ], level: 'debug' }
  }
});

const logger = log4js.getLogger();
logger.level = "debug";
logger.debug("Some debug messages");

const logger2 = log4js.getLogger("batchLog");
logger2.level = "debug";
logger2.debug("Some debug messages");

console.log('Hello World!');

Command:

npx tsc index.ts && node index.js

Output:

Hello World!

Directory listing:

│   cheese.log
│   index.js
│   index.ts
│   package-lock.json
│   package.json
│
├───logs
│       batchLog.log
│
└───node_modules

@nabe1653
Copy link
Author

nabe1653 commented Jan 12, 2024

Hi @lamweili , sorry about late to reply.
In my environment, I feel esbuild may have problem to use only multiple file.

This sample installed esbuild and add npm script to reproduce: esbuild.zip

> npm i
> npm start
Hello World!
> npm run esbuild
}) - appender "batchLog" is not valid (type "multiFile" could not be found)

And I tried to grep node_modules but not found "multiFile" word even there's option name and multiFile.js file.
So I feel esbuild, webpack or some bundle tool may cut off about multiFile.js as no imported.

It may be not your support range but I would be glad if you help us.

@nabe1653
Copy link
Author

Hi @lamweili

I may have identified a potential source of the issue and have created a PR to fix it. Could you please review it and merge it if it is satisfactory?

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

Successfully merging a pull request may close this issue.

3 participants