Log duplication when querying a workflow

MyWorkflow {

    myWorkflowMethod() {
        log.info("Workflow Started");
        log.info("Workflow Completed");

    myQueryMethod() {
        return "Hello World";

Everytime I invoke the query method from temporal web, I see the "Workflow Started" and "Workflow Completed" log messages.

From what I understand, this is an expected behaviour as Temporal internally replays the workflow execution before fullfilling the query method.
Am I correct?

Is there a way to prevent duplicate logs?

Are you using a custom logger or the replay-safe Workflow logger?

private Logger logger = Workflow.getLogger(this.getClass().getName());

Inside workflow code you should use this logger. For activities you can apply your own logger mechanism without issues.

got it.
I am using custom logger. Will change it to replay safe logger.