在 oc4j 10.1.3 中使用 log4j

发布于 2024-08-03 07:19:49 字数 662 浏览 3 评论 0原文

我有一个在 OC4J 10.1.3 上运行的 Web 应用程序。我正在尝试使用 log4j 进行一些日志记录。这些消息按预期显示在我的 IDE 控制台中,但 OC4J 中的 application.log 中没有任何内容。有人知道我需要做什么才能使其正常工作吗?

这是我的 log4j.properties:

log4j.rootCategory=DEBUG, CON1

# CON1 is set to be ConsoleAppender sending its output to System.out
log4j.appender.CON1=org.apache.log4j.ConsoleAppender
log4j.appender.CON1.layout=org.apache.log4j.PatternLayout
log4j.appender.CON1.layout.ConversionPattern=%p: [%l] - %m%n

log4j.logger.org.apache.ojb.broker.accesslayer=DEBUG

在我的 java 类中我正在这样做:

Logger logger = Logger.getLogger(getClass().getName());
logger.debug("Test message.");

I have a web application running on OC4J 10.1.3. I am trying to do some logging using log4j. The messages show up in my IDE console as expected, but nothing is going into the application.log in OC4J. Anybody know what I need to do to get this working?

Here's my log4j.properties:

log4j.rootCategory=DEBUG, CON1

# CON1 is set to be ConsoleAppender sending its output to System.out
log4j.appender.CON1=org.apache.log4j.ConsoleAppender
log4j.appender.CON1.layout=org.apache.log4j.PatternLayout
log4j.appender.CON1.layout.ConversionPattern=%p: [%l] - %m%n

log4j.logger.org.apache.ojb.broker.accesslayer=DEBUG

And in my java classes I'm doing this:

Logger logger = Logger.getLogger(getClass().getName());
logger.debug("Test message.");

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

云醉月微眠 2024-08-10 07:19:49

配置 OC4J 将控制台输出记录到文件中。
如果您使用完整的 IAS,请将其添加到 opmn.xml

<data id="oc4j-options" value="-verbosity 10 -err err.log -out out.log"/>

如果您使用独立 OC4j:

  java -jar oc4j.jar -err err.log -out out.log

Configure OC4J to log the console output to a file.
If you are using the full IAS add this to the opmn.xml

<data id="oc4j-options" value="-verbosity 10 -err err.log -out out.log"/>

If you are using the stanalone OC4j:

  java -jar oc4j.jar -err err.log -out out.log
屋顶上的小猫咪 2024-08-10 07:19:49

OC4J 开发人员指南说明了 log4j 的用途用于 OC4J

具体来说,log4.properties 应放置在 WEB-INF/classes 中,log4j 运行时 jar 可以找到它(通常放置在 WEB-INF/lib 中)。将 log4j 工件放在 applib 目录中是不好的做法,应该避免。

我不确定这一点,但如果 log4j 没有写入 application.log,那么您必须检查 ODL 日志的内容(ODL 配置的一些详细信息可在 开发人员指南),如果 OC4J 由 OPMN 管理,那么也是一个好主意检查 opmn/logs 目录中的托管进程控制台日志。

The OC4J Developer's Guide states how log4j is to be used in OC4J.

Specifically, log4.properties should be placed in WEB-INF/classes where it can be located by the the log4j runtime jar (usually placed in WEB-INF/lib). Placing the log4j artifacts in the applib directory is bad practice and should be avoided.

I'm unsure of this, but if log4j is not writing to application.log, then you must check the contents of the ODL log (some details of ODL configuration are available in the Developer's Guide), and if OC4J is managed by OPMN it is also a good idea to check the managed process console log in the opmn/logs directory.

℉服软 2024-08-10 07:19:49

我知道这是一个老问题,但今天早些时候我对此做了一些额外的研究。

事实证明,OC4J 包含一个 OracleAppender 对于 Log4j。这是 log4j.properties 中的示例配置:

log4j.appender.OJDL=oracle.core.ojdl.log4j.OracleAppender
log4j.appender.OJDL.LogDirectory=${oracle.j2ee.home}/log/oc4j
#log4j.appender.APP1.MaxSize=1000000
#log4j.appender.APP1.MaxSegmentSize=200000
#log4j.appender.APP1.Encoding=iso-8859-1
log4j.appender.OJDL.ComponentId=OracleProd

此配置将 log4j 消息定向到 ORACLE_HOME/j2ee/home/log/oc4j/log.xml 文件,LogViewer 会读取该文件,然后将其作为诊断日志显示在 Application Server Control 中。

然后可以将其添加为某种级别的记录器。例如,除了记录到控制台之外,要将其添加到根记录器:

log4j.rootLogger=DEBUG, CON1, OJDL

注意:我不确定 rootLoggerrootCategory 之间有什么区别。

注 2:这会显示在诊断日志中,而不是应用程序日志中。

I know this is an old question, but I did some additional research into this earlier today.

It turns out that OC4J includes an OracleAppender for Log4j. This is the sample configuration for it that would go in log4j.properties:

log4j.appender.OJDL=oracle.core.ojdl.log4j.OracleAppender
log4j.appender.OJDL.LogDirectory=${oracle.j2ee.home}/log/oc4j
#log4j.appender.APP1.MaxSize=1000000
#log4j.appender.APP1.MaxSegmentSize=200000
#log4j.appender.APP1.Encoding=iso-8859-1
log4j.appender.OJDL.ComponentId=OracleProd

This configuration directs log4j messages into the ORACLE_HOME/j2ee/home/log/oc4j/log.xml file, which LogViewer reads and then displays in Application Server Control as Diagnostics Logs.

This can then be added as a logger at some level. For example, to add it to the root logger in addition to logging to the console:

log4j.rootLogger=DEBUG, CON1, OJDL

Note: I'm not sure what the difference is between rootLogger and rootCategory.

Note 2: This shows up in the Diagnostics log rather than the application log.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文