简体   繁体   中英

Log4j on AppEngina -> All log messages shown with the same log level

My log messages always show up as "info" in the app engine logging console, even if i log a message as error (see screenshot).

I log a message like that:

private static Logger logger = Logger.getLogger(PingServlet.class);
logger.error("Database was successfully pinged!!.");

The configs like this:

src/main/resources/log4j.properties

# Root logger option
log4j.rootLogger=INFO, stdout

# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

src/main/webapp/WEB-INF/logging.properties

# A default java.util.logging configuration.
# (All App Engine logging is through java.util.logging by default).
#
# To use this configuration, copy it into your application's WEB-INF
# folder and add the following to your appengine-web.xml:
# 
# <system-properties>
#   <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
# </system-properties>
#

# Set the default logging level for all loggers to WARNING
.level = INFO

在此处输入图片说明

How can I change that? I want to show an error as error and so on.

If you are logging with log4j the log messages are being printed to the "console" with ConsoleAppender which AppEngina then collects in its own log. The two log parts you have are not connected.

you either need to use java.util.logging directly instead of log4j or use slf4 to redirect log4j to java.util.logging (a bit tricky, read the documentation carefully)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM