0

I have a java application and I am using log4j2. I want to only log the log message without logging things like className, log level, timestamp etc. I do see some suggestions regarding custom appender etc. But isn't there a simpler way to achieve this by just modifying the default configuration ?

Example:

log.info(" Hi This is a log message");

Desired Log statement

Hi This is a log message
Andy897
  • 6,915
  • 11
  • 51
  • 86

1 Answers1

2

You have to change config file log4j.xml

The element need to be change in that file is pattern :
if you are using log4j.properties then change corresponding element.
example of pattern element:

<PatternLayout pattern="%d [%p] %c %m%n"/>


here d id for date
p is for priority
c is for Class Name
m is fro message
n is fro separator
if you dont want any thing then remove from pattern entry.

Modified as per your requirement

<PatternLayout pattern=" %m%n"/>
TheSprinter
  • 1,523
  • 17
  • 30