Skip to content

Function's context's logger does not log to the log-topic #7814

Closed
@YArane

Description

Describe the bug
When using the context's logger, log messages are not produced on the function's log topic.
Relevant docs: https://pulsar.apache.org/docs/en/functions-debug/#use-log-topic

To Reproduce
Steps to reproduce the behavior:

  1. Create a Pulsar Function which logs a message using the context's logger (see LoggingFunction.java example below)
  2. Deploy said function using pulsar-admin specifying a log-topic in the create command
  3. Trigger the function / produce a message on one of its input topics
  4. Log messages appear in the function's log file only

Expected behavior
Expected to see the log message produced on the function's log topic in addition to being printed to the log file.

Screenshots

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LoggingFunction implements Function<String, Void> {
    @Override
    public void apply(String input, Context context) {
        Logger LOG = context.getLogger();
        Logger LOG2 = LoggerFactory.getLogger(this.getClass);
        LOG.info("This message appears in log file only")
        LOG2.info("This message appears in log file AND log topic")
    }
}
$ bin/pulsar-admin functions create \
  --log-topic persistent://public/default/logging-function-logs \
  # Other function configs

Desktop (please complete the following information):

  • OS: iOS

Additional context
Pulsar 2.6.0 running in standalone mode (not in a docker container)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    area/functiontype/bugThe PR fixed a bug or issue reported a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions