This is my log4j.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="${catalina.base}/logs/server.log" />
<param name="Append" value="true" />
<param name="Threshold" value="INFO" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE}#%X{requestId}#%X{uid}#%X{agentId}#%X{agentName} %-5p [%c{1}] - %m%n" />
</layout>
</appender>
<logger name="org.springframework" level="DEBUG">
<appender-ref ref="FILE"/>
</logger>
I am making a JSON request to a controller and getting 400 Bad request request is syntactically incorrect
. I want to get some more info on this. I read about enabling spring debugging and followed instructions but it doesn't work. I have checked my request and it seems completely fine. How can I see more information about this in server.log file? Why does the above configuration not work?
PS: I have removed the other loggers and appenders for clarity
This fixed it
Here is the dependencies:
Here is the log4j2 configuration:
Bellow configuration is for windows machine. You can change only the log path for linux.
Here contains some keyNote:
Here,
filename
is the name of the log file.Here,
logPatternConsole
has the time pattern.In Appender section, it has
here
SizeBasedTriggeringPolicy
defins when new log file will created. Here, after 10MB it will create new logFileHere is the log implementation:
Check bellow for
LogWriterUtility
class:Thanks :)