#(log4j2) loggger.info doesnt print in console
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
I uploaded your attachments as Gist.
can you share your log4j2.xml configuration as well
where is that in my project?
in your resources folder ig
resources folder is empy
then you didnt even configured log4j2 correctly
yeah, can you show me? i am learning log4j2 rn and icant find any good guides online
this would be the full documentation: https://logging.apache.org/log4j/2.x/manual/configuration.html
but you basically need this to start: https://www.baeldung.com/log4j2-appenders-layouts-filters#default-configuration
ok
i am using this
my log4j2.xml file looks like this now
<Appenders>
<Console name="stdout" target="SYSTEM_OUT">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %p %m%n"/>
</Console>
</Appenders>
</Configuration>
<Loggers>
<Root level="error">
<AppenderRef ref="STDOUT"/>
</Root>
</Loggers>```
but log4j2 is saying [Fatal Error] log4j2.xml:8:2: The markup in the document following the root element must be well-formed.
ok. now my xml file is like this. it works well.<Configuration status="info" name="org.legoaggelos.Main" packages=""> <Appenders> <Console name="stdout" target="SYSTEM_OUT"> <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %p %m%n"/> </Console> </Appenders> <Loggers> <Root level="info"> <AppenderRef ref="stdout"/> </Root> </Loggers> </Configuration>
I read a bit more, and i changed the root level to info. now logger.info("..."); actually prints stuff!
I have another question now, in the site, it shows this block of code that makes the logger log to baeldung.log.
<File name="fout" fileName="baeldung.log" append="true">
<PatternLayout>
<Pattern>%d{yyyy-MM-dd HH:mm:ss} %-5p %m%n</Pattern>
</PatternLayout>
</File>
</Appenders>```
is there any way i can change where baeldung.log will be created?