Will it be possible to just print the error message in console using log4j without including date, time and severity details.
Log 4j.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="threshold" value="ERROR" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyyMMdd HH:mm:ss,SSS} - %p | %m%n" />
</layout>
</appender>
<logger name="package" >
<level value="ERROR" />
<appender-ref ref="CONSOLE" />
</logger>
<root>
<priority value="ERROR" />
<appender-ref ref="CONSOLE" />
</root>
</log4j:configuration>
You can check various ways of tweaking the output of log4j in Pattern Layout . You could try using the following pattern layout to print only the message that has to be logged to console
<param name="ConversionPattern" value="%m%n" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.