Printing messages in JBoss

I am using JBoss 3.2.3. When I print a message from my code using System.out.println(), this is how it get printed on Console and server.log:

yyyy-mm-dd hh:mm:ss,SSS INFO [STDOUT] <message>

where <message> is the message I am printing.

This is the format I want my messages to use when i print them using System.out.println():

yyyy-mm-dd hh:mm:ss, SSS <message>

Can anybody tell me how to do this thing? Thanks

[465 byte] By [tv1970usa] at [2007-10-2 6:43:51]
# 1
You'll need to learn how to configure properly LOG4J. Please read the documentation at http://logging.apache.org/log4j/docs/index.htmlYou'll need to edit the log4j.xml that resides in the server\default\conf directory.
edsonwa at 2007-7-16 13:52:17 > top of Java-index,Java Essentials,Java Programming...
# 2

> You'll need to learn how to configure properly LOG4J.

>

> Please read the documentation at

> http://logging.apache.org/log4j/docs/index.html

> You'll need to edit the log4j.xml that resides in the

> server\default\conf directory.

thanks for your reply. I look at the log4j.xml, read the document and figure out that I have to made the changes in ConversionPattern for CONSOLE and FILE appenders. So I change it to

<param name="ConversionPattern" value="%d %m%n"/>

It works perfect for my messages. And my messages are printed in this format :

yyyy-mm-dd hh:mm:ss,SSS <message>

Unfortunately the other messages (not my application messages) are also being printed in this new format which is a big no for our company.

I only want my messages to be printed in the new format. Can you help me in this regard? Thanks

tv1970usa at 2007-7-16 13:52:17 > top of Java-index,Java Essentials,Java Programming...
# 3

So in case of CONSOLE, for messages which I am printing from my classes, i want to use

<param name="ConversionPattern" value="%d %m%n"/>

But messages from other programs (JBoss, Apache etc.) I want to use

<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>

Now the point is how to differentiate between my application messages (which are being printed using system.out.println) and other messages. For that the answer is the first 5 characters of all my application messages are either "PEND:" or "WEBF:".

Now is it possible that i can use different ConversionPattern based on the message I am receiving? If not then is there any other way to accomplish the task? I want to do the same thing for FILE.

Thanks

tv1970usa at 2007-7-16 13:52:17 > top of Java-index,Java Essentials,Java Programming...
# 4
Anyone please? Thanks
tv1970usa at 2007-7-16 13:52:17 > top of Java-index,Java Essentials,Java Programming...
# 5

> So in case of CONSOLE, for messages which I am

> printing from my classes, i want to use

> > <param name="ConversionPattern" value="%d %m%n"/>

>

> But messages from other programs (JBoss, Apache etc.)

> I want to use

> > <param name="ConversionPattern" value="%d{ABSOLUTE}

> %-5p [%c{1}] %m%n"/>

>

> Now the point is how to differentiate between my

> application messages (which are being printed using

> system.out.println) and other messages. For that the

> answer is the first 5 characters of all my

> application messages are either "PEND:" or "WEBF:".

>

> Now is it possible that i can use different

> ConversionPattern based on the message I am

> receiving? If not then is there any other way to

> accomplish the task? I want to do the same thing for

> FILE.

>

> Thanks

What you are trying to do is not possible with Log4j as far as I know. But this definitely would be a nice feature: "changing output format dynamically based on message content".

uryl99a at 2007-7-16 13:52:17 > top of Java-index,Java Essentials,Java Programming...