on 03-03-2021 6:55 AM
Hi,
I want to use Kibana Dashboard for the logs of the CDS requests in CAP. Unfortunately, neither the library cf-nodejs-logging-support nor @sap/logging have a documentation on how to use them with CAP.
I have the following issue: To try it, I did use the sample data from the project generator in Business Application Studio - so a bookshop with books and orders as entities.
My catalog service has the following code:
const log = require('cf-nodejs-logging-support');
const ResourceManager = require('@sap/textbundle').ResourceManager;
const bundle = new ResourceManager('_i18n/messages');
// Set the minimum logging level (Levels: off, error, warn, info, verbose, debug, silly)
log.setLoggingLevel("warn");
module.exports = (srv) => {
const { Books, Orders } = srv.entities;
srv.before('CREATE', Orders, async (req) => {
const localTexts = bundle.getTextBundle( req.locale);
const book = await SELECT.one(Books).where({ ID: req.data.books_ID })
if ( book.title == "Wuthering Heights" ) {
req.warn(localTexts.getText('TITLE'), "Reg.warn");
}
if (book.stock < req.data.amount) {
if (req.messages) {
log.warn(req.messages);
}
log.error(localTexts.getText('ORDER_EXCEEDS_STOCK', [req.data.amount, req.data.amount - book.stock]));
req.reject(400, localTexts.getText('ORDER_EXCEEDS_STOCK', [req.data.amount, req.data.amount - book.stock]));
}
})
}
When I send a request which should show both a warning and an error, in Kibana I get the following output (see picture)
You can see the logs I created via code at the bottom PLUS everything the application logs itself.
My questions are:
Thank you in advance! A solution would be really helpful to use Kibana without having to filter it manually every time.
Hi shorstmann,
Which version are you using? This was caused by a reuse component splitting by linebreak and should be fixed in cds^4.6.
Best,
Sebastian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi shorstmann,
I can confirm there is still an issue. We're in the process of improving our observability (guidance) and will look at this. I'll have to ask you to stay tuned and watch our release notes in the upcoming months.
Thanks and best,
Sebastian
@SAP
Is there or was there an fix of this issue?
We have the same problem using CAP Node.js.
- Log Levels are not reflected in Kibana (it logs Server Crashes as "INFO" should be "ERROR") -> Important for Tracing, currently we are faster by exporting Logs and using Nodepad++ Search
- Error objects logged are splitted on many lines (in my opinion a fix here would only be a quality of life feature)
User | Count |
---|---|
68 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.