Open dooznvcs opened 1 year ago
I reopen this issue because I still don’t have the solution... Even using the Adding your own logger to the container example, the instance of my logger is still not active. Even copying the example, the custom logger didn’t work.
I changed my code this way:
import { dockStart } from '@nlpjs/basic';
import { MyCustomLoggerClass } from './some-file';
const dock = await dockStart(this.options.dock);
const container = dock.getContainer();
const manager = dock.get('nlp');
container.register('logger', new MyCustomLoggerClass());
manager.addCorpus(corpusFilePath);
await manager.train();
Hello, You're correctly changing the logger. The problem is that the neural trainer does not use the logger from the container. When the neural trainer is created it accepts a setting "log" that can be true to use the default console, false to don't log or a function to use this function to log. https://github.com/axa-group/nlp.js/blob/master/packages/neural/src/neural-network.js#L40
You can change the function that logs the neural trainer:
const { dockStart } = require('@nlpjs/basic');
(async () => {
const config = {
settings: {
nlp: {
nlu: {
log: (status, time) => console.log(`custom log: ${status.iterations} ${status.error} ${time}ms`),
},
corpora: [
"./corpus-en.json"
]
}
},
use: ["Basic"]
}
const dock = await dockStart(config);
I would like to change the dock logger so I can use my own I use the example given here to register my own logger
But the logs still remain unchanged