• Create a logger for the given message context, if available.

    Usage: To create a logger in your module, it is recommended to pass a module identifier that will be logged as messageContext for all messages from this logger: const logger = createLogger('my-module');. Not setting any module identifier will retrieve the default logger. Use this logger throughout your module. If the module is spread over multiple files, you can retrieve the logger instance by calling the createLogger function with the respective module identifier. There will always be only one instance of a logger per module identifier. You can pass any custom data that you want to be logged in addition by passing an object instead. You can change the default logging level (INFO) using the level key in the object. In those cases, provide the messageContext as a key in the object:

    const logger = createLogger({
    messageContext: 'my-module',
    myCustomKey: 'my-custom-data',
    level: 'debug'
    });

    You will find these information under the custom_fields key in your Cloud Foundry logs.

    To retrieve a logger after its creation use getLogger. If you want to change the log level of a logger use setLogLevel.

    Returns

    A newly created or an already existing logger for the given context.

    Parameters

    • Optional messageContext: string | MessageContextObj & LoggerOptions

      Either a key for the message context of all messages produced by the logger or an object with additional keys to set in the message.

    Returns Logger

Copyright Ⓒ 2023 SAP SE or an SAP affiliate company. All rights reserved.