You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to add a custom log4.properties file with content:
log4j.rootLogger=TRACE, STDOUT
# CONSOLE appender not used by default
log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
log4j.appender.STDOUT.layout.ConversionPattern=%m
yet this setting is being ignored :(
The output I receive is 09:52:32.723 [main] INFO com.blabla.Test - {"message":"It works!","test":"blaaaa","level":"INFO","thread_name":"main","class":"com.blabla.Test","@timestamp":"2017-11-08 09:52:32.713+0100"}
yet I want it to be {"message":"It works!","test":"blaaaa","level":"INFO","thread_name":"main","class":"com.blabla.Test","@timestamp":"2017-11-08 09:52:32.713+0100"}
I use it in my code like this:
import com.savoirtech.logging.slf4j.json.LoggerFactory;
import com.savoirtech.logging.slf4j.json.logger.Logger;
public class Test {
public static void main(String[] args) {
LoggerFactory.setIncludeLoggerName(false);
Logger logger = LoggerFactory.getLogger(Test.class);
logger.info().message("It works!").field("test", "blaaaa").log();
}
}
Any help would really be appreciated :)
Regards
Anna
The text was updated successfully, but these errors were encountered:
This looks to be an issue at the log4j level. I can help track down the problem if provided a (preferably minimal) project that demonstrates the problem.
Note that I took the example Test code provided and put it into my own test project and it worked as desired.
To run, mvn clean package then mvn exec:java -Dexec.mainClass=sandbox.log4j.Log4jTest.
Note that the output will look a little garbled because the log4j pattern does not include a newline at the end, making the next line of output, from maven, append to the end of the actual log4j line.
Hope this helps. Based on my experience, the most common cause of log4j output mis-formatting is having more than one log4j configuration file on the classpath.
Hi :)
I wanted to add a custom log4.properties file with content:
yet this setting is being ignored :(
The output I receive is
09:52:32.723 [main] INFO com.blabla.Test - {"message":"It works!","test":"blaaaa","level":"INFO","thread_name":"main","class":"com.blabla.Test","@timestamp":"2017-11-08 09:52:32.713+0100"}
yet I want it to be
{"message":"It works!","test":"blaaaa","level":"INFO","thread_name":"main","class":"com.blabla.Test","@timestamp":"2017-11-08 09:52:32.713+0100"}
I use it in my code like this:
Any help would really be appreciated :)
Regards
Anna
The text was updated successfully, but these errors were encountered: