Skip to content

Tag: logback

Get PID in logback log file

When using logback outside of Spring-Boot, how can I get the ProcessID into the log file name? In the RollingFileAppender I’d like to define: How can I get the ${PID} set or is there a standard way of obtaining this? Answer Learn how to get the own PID from inside the JVM – How can a Java program get its

logback don’t log exception into file which throwed from an ThreadPoolTaskExecutor pool thread

I’ve got an wired problem, that seems like the logback only print my Exception stack trace on the console,rather than log it into an log file. The following is my experiment codes, I used an spring boot test with two thread pool,which simulating my production codes.Both thread print a log and throws an RuntimeException.But the exception info only print on

When not to use AsyncAppender in logback by default

Logback supports using an async appender with the class ch.qos.Logback.classic.AsyncAppender and according to the documentation, this will reduce the logging overhead on the application. So, why not just make it the default out of the box. What usecases are better served by using a sync appender. One problem I can see with the Async appender is that the log messages

How to change log level only for current thread with Logback

In Logback, the log level of a logger can be changed with setLevel() method. But in Logback, because the loggers are singleton, the call of setLevel() method will affect to all other threads that use same logger. Now I have a class used in a web application like this: And in Spring ApplicationConfig.xml: I want to log call of insertRecord