1

异常的 log4j.category.DataNucleus 是什么?因此,我试图将 Log4j 与 Google App Engine 一起使用,但是在测试期间,Lo4j 没有拾取异常(它们被仪表板拾取)。

我也希望所有的错误都被拾起。所以我把它添加到主类中。这会发现所有错误,包括命运吗?

   logger.fatal ("App Error");

好的,所以我尝试了这个:

 }
     catch(Exception e) {
            logger.warn("Log4j has caught n exception!", e);
            e.printStackTrace();
        }

然而,异常显示在仪表板中,但不是 log4j 正在接收它,因为它没有给我“Log4j 已捕获 n 异常!”。

4

1 回答 1

0

异常的 log4j.category.DataNucleus 是什么?

log4j.logger.DataNucleus

一般的

我不使用 Eclise 也不使用 Log4J(当然,DataNucleus 使用它除外)。我的日志配置文件中有以下内容。

log4j.properties

log4j.appender.A1 = org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout = org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern = %d{HH:mm:ss,SSS} (%t) %-5p [%c] - %m%n

[...]

# Tighten logging on the DataNucleus categories to WARN.
# This DataNucleus logging configuration appears redundant; in production,
# DataNucleus uses Java logging instead.
log4j.logger.DataNucleus                 = WARN, A1
log4j.logger.DataNucleus.JDO             = WARN, A1
log4j.logger.DataNucleus.Persistence     = WARN, A1
log4j.logger.DataNucleus.Query           = WARN, A1
log4j.logger.DataNucleus.Lifecycle       = WARN, A1
log4j.logger.DataNucleus.Cache           = WARN, A1
log4j.logger.DataNucleus.MetaData        = WARN, A1
log4j.logger.DataNucleus.Management      = WARN, A1
log4j.logger.DataNucleus.General         = WARN, A1
log4j.logger.DataNucleus.Connection      = WARN, A1
log4j.logger.DataNucleus.Transaction     = WARN, A1
log4j.logger.DataNucleus.Datastore       = WARN, A1
log4j.logger.DataNucleus.ClassLoading    = WARN, A1
log4j.logger.DataNucleus.Plugin          = WARN, A1
log4j.logger.DataNucleus.ValueGeneration = WARN, A1
log4j.logger.DataNucleus.Enhancer        = WARN, A1
log4j.logger.DataNucleus.SchemaTool      = WARN, A1

日志记录属性

handlers = java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level = ALL
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

[...]

# Set the default logging level for ORM, specifically, to WARNING
DataNucleus.level                 = WARNING
DataNucleus.JDO.level             = WARNING
DataNucleus.Persistence.level     = WARNING
DataNucleus.Query.level           = WARNING
DataNucleus.Lifecycle.level       = WARNING
DataNucleus.Cache.level           = WARNING
DataNucleus.MetaData.level        = WARNING
DataNucleus.Management.level      = WARNING
DataNucleus.General.level         = WARNING
DataNucleus.Connection.level      = WARNING
DataNucleus.Transaction.level     = WARNING
DataNucleus.Datastore.level       = WARNING
DataNucleus.ClassLoading.level    = WARNING
DataNucleus.Plugin.level          = WARNING
DataNucleus.ValueGeneration.level = WARNING
DataNucleus.Enhancer.level        = WARNING
DataNucleus.SchemaTool.level      = WARNING

logger.fatal(“应用程序错误”);

我从未编写过 Log4J。这个命令是否不只是记录"App Error"致命级别的文本条目?

享受?

于 2013-04-02T16:45:19.560 回答