1

I have a Java Quarkus application which is using JBoss for logging.

I am using a scheduled job via io.quarkus.scheduler.Scheduled like so:

private static final Logger LOGGER = Logger.getLogger(ReportFetchTask.class);

...

@Scheduled(every = "1h", identity = "test", concurrentExecution = SKIP)
    public void fetchData() {
        LOGGER.info("Fetching data...");
    }

The Quarkus docs https://quarkus.io/guides/scheduler-reference#identity mention that the identity field is used in log messages, but it does not appear.

I tried adapting the log format to quarkus.log.console.format=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c{3.}] (%t) [identity:%X{identity}] %s%e%n assuming that the identity might be added to the MDC (https://quarkus.io/guides/logging#use-mdc-to-add-contextual-log-information), but that does not seem to be the case:
2025-11-17 17:02:25,004 INFO [x.x.x.x] (vert.x-worker-thread-1) [identity:] Fetching data...

How can I let the identity show up in the log message? The documentation made it seem like this would happen automatically but I couldn't find anything on how to set this up. I guess I could add it manually via the MDC myself, but then what is the purpose of the identity field?

I also have logs that aren't made in scheduled tasks, so for those logs ideally the identity field would not show up at all.

1 Answer 1

3

identity in @Scheduled is only used by Quarkus’ own scheduler logs, not by your application logger. Quarkus does not place the identity into the MDC, so %X{identity} will always be empty unless you explicitly write it.If you want the scheduler identity to appear in your own log messages, you must add it to the MDC yourself. The usual pattern is:

@Scheduled(every = "1h", identity = "test")
void fetchData() {
    try (MDC.MDCCloseable ignored = MDC.putCloseable("identity", "test")) {
        LOGGER.info("Fetching data...");
    }
}

Your log format can then use %X{identity} and it will print correctly. Quarkus doesn’t currently provide any built-in way to auto-propagate the scheduled job identity into application-level logs.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.