本文介绍了WAS日志记录 - Java Util Logging和Log4j的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻求以下确认:


  1. 使用Websphere Application Server管理控制台,我们可以指定一些日志记录配置还显示了应用程序的类(如下所示)。如果我在WAS控制台中启用日志记录,它是否只有在我的应用程序(以及其中提到的其他类)已实现JUL的情况下才能工作?

  1. Using Websphere Application Server Admin Console, we can specify some logging configurations and that shows classes of your application also (as shown below). If I enable logging in WAS console, will it work only if My Application (and other classes which are mentioned in there) have JUL implemented into it?

默认情况下,使用WAS控制台的日志记录在跟踪文件($ {SERVER_LOG_ROOT} /trace.log)中完成。这可以用于控制台吗? (我想是的,只需将其更改为$ {SERVER_LOG_ROOT} /SystemOut.log)

By default the logging using WAS console is done in the trace file (${SERVER_LOG_ROOT}/trace.log). Can this be made to console also? (I think yes, just be changing it to ${SERVER_LOG_ROOT}/SystemOut.log)

有没有办法从WAS控制台配置Log4j属性? (我认为没有,因此我们需要使用其他方法使Log4j可配置)。

Is there any way to configure Log4j properties also from WAS console? (I think no, thus we need to use other ways to make it Log4j configurable).

PS:我明白了JUL提供了抽象以及它自己的实现。上述问题要求牢记JUL的实施:)

PS: I understand that JUL provides abstraction as well as its own implementation. The above questions are asked keeping JUL implementation in mind :)

推荐答案

Hello
我们刚刚通过相同的练习:使用WAS时JUL vs Log4j。我们决定选择Log4j。

HelloWe just when through the same exercise: JUL vs Log4j when using WAS. We decided to go for Log4j.

1)如果你的应用程序使用JUL,你应该可以从该控制台更改Level。

1) Yes if your App use JUL, you should be able to change the Level from that console.

2)我不确定。

3)你不能从WAS控制台更改Log4j。在我们的例子中,我们创建了一个简单的MBean,因此我们可以控制每个WebApp的Lo4j日志级别(通过wsadmin)。 BEA还提供了一个简单易用的JSP,您可以在WebApp中包含一个UI来查看每个类别。

3) No you cannot change Log4j from WAS Console. In our case we created a simple MBean so we could control the Lo4j log Level of each WebApp (via wsadmin). There is also a nice and simple JSP from BEA that you can include in you WebApp to have a UI to see each category.

如果您决定使用JUL(超过log4j),请务必了解以下含义:

If you decide to use JUL (over log4j), make sure to understand the following implication:


  • JUL doest没有很多开箱即用的处理程序。

  • JUL doest not have many out-of the box Handlers.

JUL处于JVM级别,所有应用程序都将分享它。如果您开发自定义JUL Hanlder,则所有WebApp将共享相同的实例。

JUL is at the JVM Level, All you App will share it. If you develop custom JUL Hanlder, all WebApp will share the same Instance.

由于JUL处理程序很常见,因此很难将每个应用程序拆分为单独的日志文件(每个WebApp一个)。

Because JUL Handler are common, it is hard to split Each App in a separate logfile(one per WebApp).

当使用第三方Lib(Spring,Ibatis等)时,如果你使用JUL,当你在Spring上将日志级别更改为DEBUG时,它将是为所有WebApp改变了。如果你需要更精细的粒度(在特定的WebApp上更改Spring的级别),那么最好在每个WebApp中嵌入Log4j。

When using third party Lib (Spring, Ibatis etc) and if you use JUL, when you will change the Log Level to DEBUG on Spring, it will be changed for ALL you WebApp. If you need more fine grain (changing level on Spring on a specific WebApp) then it is better to embed Log4j in each WebApp.

希望这会对你有所帮助

这篇关于WAS日志记录 - Java Util Logging和Log4j的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 11:44