0

I have a program in which I'm using slf4j with logback for logging and there is different type of logging pattern for clients and developers, like below:

if(userType.equals("clients")){
    encoder.setPattern("[%5level] - %date{dd MMM yyyy;HH:mm:ss.SSS} : %message%n");
}else{
    encoder.setPattern("[%5level] - %date{dd MMM yyyy;HH:mm:ss.SSS} [%thread]: %message%n");
}

But I cannot apply the above code using configuration file because it won't give me the feasibility to do it. Now I have applied markers in the logs and want to print only those logs which have marker in them. And for that I need to use configuration file. Is there any way in which I can print the logs with markers without using the configuration file.

  • 1
    Not sure if it solves your problem, but the current code [has a big issue](https://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java). – f1sh Nov 24 '22 at 12:33
  • 1
    I see another approach, to have two different log files, one for client and another one for developers. Adding to @f1sh comment, I suggest you to use camel case when naming variables to follow Java standard: `userType.equals("clients")` – Leonardo Emmanuel de Azevedo Nov 24 '22 at 12:51

0 Answers0