0

I want my messages to be added whenever we are logging something . For example if i am logging

log.info("Hello");

The message should be appended with some id which will be from my application.So the final logging message printed on console will be

Hello 1 Hello 2

Do i need to add an appender for this . If yes how can i achieve it using logback ?

Sanket
  • 612
  • 5
  • 23
  • I don't understand very well what u need. You would like add automatically an id into the message ? – MychaL Feb 13 '13 at 09:54
  • Yes exactly i want some id to be appended into the message each time when we log something. – Sanket Feb 16 '13 at 12:23

1 Answers1

0

Why don't you manage this id yourself ?

Each time, you are logging something you can call the method with a parameter :

log.info("Hello {}", id);

But what is the interest of doing that ? Are you trying to identify the session ?

MychaL
  • 969
  • 4
  • 19
  • 37
  • Try with a sifintAppender maybe ? create a configuration with a discriminator and set the MDC value to identify what you want. – MychaL Feb 18 '13 at 10:03
  • I will need to change the existing code in every log statements for that. I want to make sure that this id gets appended , so whenever i look at the logs i have that basic information. – Sanket Feb 18 '13 at 11:44