-
Notifications
You must be signed in to change notification settings - Fork 57
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
Logging File log empty #3142
Comments
Hello @luizcarlospedrosogomes, I had a quick and compared to our test case for the logger. I experienced the behaviour, that I needed to create the logger before I set the global transport. Could you perhaps change the order in your code so that the I guess these methods only effect existing logger. Let me know if this helps. Best |
@FrankEssenberger thanks! I imagine the problem must be in the call in server.js. But I need to leave this dependency isolated in a file |
Good morning @luizcarlospedrosogomes, I think the order is still set before creation. As you wrap the const logger = ({name}=>{
const myLogger = createLogger(name);
setGlobalTransports(fileTransport);
return myLogger
} Best |
Good morning @FrankEssenberger Sorry for the delay, I followed your suggestion but I got another error ` const logger = ({ name }) => { module.exports = logger;
[cds] - loading server from { file: 'srv/server.js' } |
Good morning, at least the stream seems to be considered now :-). I found an issue which seems to be also the problem here. Something with passing things as reference not value in the I think it would be good to simplify the situation and put the logger creation all in the same file to see where the passing around causes a problem. So first put logger creation in the server.js (just as a test). When this works step by step move the code to a function like you have and see when it breaks. Best |
server.js ... setGlobalTransports(fileTransport);
db/schema.cds That way, despite the log indicating the need for some intention, it worked, but now how to make it work in isolation? |
winstonjs/winston#1573 (comment) I followed this comment fully, implemented the code that is as an example. It worked I have the log files too. But the sap package, this package, was left out. |
hm, I do not know. This is issue is strange and I can not reproduce it. I think there must be some problem with calling things by reference creating shallow copies if you adjust a logger after creation. This is what we do when calling export const loggerBuilder = (name: string): Logger => {
const myLogger = createLogger(name);
const fileTransport = new transports.File({
filename: 'test.log',
level: 'info'
});
setGlobalTransports(fileTransport);
return myLogger;
}; If this also does not help I, I would perhaps use the code sample you found. @marikaner do you have an idea on this issue? Best |
@luizcarlospedrosogomes, it has been a long time since this issue was discussed. Were you able to solve or work around it since then? |
It was implemented as per the guidance, I didn't return to the scenario again. I must return soon |
package.json -> depedencies:
...
"@sap-cloud-sdk/util": "^2.11.0",
...
logger.js
server.js
`
const myLogger = require('./logger')({ name: 'server' });
...
myLogger.info('ok5');
...
`
file log empty
The text was updated successfully, but these errors were encountered: