you must login with an BTP account in order to see the app
2.5 KiB
Migration Guide
Version 3 ==> Version 4
Changes to application code
Application context
logLocation
and traceLocation
are no longer considered.
The library writes entries to standard output and to standard error only.
This makes providing these options unnecessary:
var logging = require('@sap/logging');
var appContext = logging.createAppContext({
// these options are unnecessary in version 4
logLocation: logging.STORAGE.CONSOLE,
traceLocation: 'path-to-file'
});
Middleware
Code like:
var logging = require('@sap/logging');
var appContext = logging.createAppContext();
// ...
app.use(logging.expressMiddleware(appContext));
should be transformed to:
const logging = require('@sap/logging');
const appContext = logging.createAppContext();
// ...
app.use(logging.middleware({ appContext: appContext }));
Loggers and tracers from application context
Code like:
appContext.getLogger('/Application/Category');
// or
appContext.getTracer(__filename);
should be transformed to one of the following variants:
- when getting a logger/tracer when a message from messaging service is received or a job run is triggered:
appContext.createLogContext().getLogger('/Application/Category');
// or
appContext.createLogContext().getTracer(__filename);
With the snippet above, the context id will be auto-generated. It is still possible to provide a custom value.
- when getting a logger/tracer for logging/tracing purposes during application startup:
appContext.createLogContext({ id: '' }).getLogger('/Application/Category');
// or
appContext.createLogContext({ id: '' }).getTracer(__filename);
Note: The context id defaults to an auto-generated value.
Therefore, it is recommended to explicitly pass an empty string as id
for the log context used on application startup to distinguish these entries from entries produced during job runs or during the processing of other events more easily.
Loggers and tracers from request context
Code like:
appContext.createRequestContext(req).getLogger('/Application/Category');
// or
appContext.createRequestContext(req).getTracer(__filename);
should be transformed to:
appContext.createLogContext({ req }).getLogger('/Application/Category');
// or
appContext.createLogContext({ req }).getTracer(__filename);
Request id
Code like:
appContext.createRequestContext(req).requestId
should be transformed to:
appContext.createLogContext({ req }).id