RE: How can I set the output color of log4j?

2008-03-17 Thread Bender Heri
Since you do not specify which displaying application shall show colors I can 
give you advice how to achieve it within the eclipse console display:

Configure two separate appenders. One for the levels WARN and higher and one 
for the levels INFO and lower. Assign them to the std.err and std.out. Here a 
config example:

























Eclipse console will display WARN and higher in red, INFO and lower in black 
color.

Heri


> -Original Message-
> From: youhaodeyi [mailto:[EMAIL PROTECTED]
> Sent: Saturday, March 15, 2008 9:50 AM
> To: log4j-user@logging.apache.org
> Subject: How can I set the output color of log4j?
> 
> 
> 
> I want to set different colors for different priority log. 
> How can I do that?
> -- 
> View this message in context: 
> http://www.nabble.com/How-can-I-set-the-output-color-of-log4j-
> -tp16065799p16065799.html
> Sent from the Log4j - Users mailing list archive at Nabble.com.
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



How to log binary data

2008-03-17 Thread teknokrat
I have a requirement to log raw binary data. This will be mostly ASCII 
characters but will contain non-displayable control characters such as 
\0, etc. My first thought was to write an appender by extending the 
FileAppender class but I cannot see how to do this as I need access to 
an OutputStream and not a Writer. Does anyone have any good ideas of how 
this can be done witht he minimum of fuss in log4j?


cheers


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to log binary data

2008-03-17 Thread Bender Heri
I for myself do such things when preparing the log message, i.e.:

if (myLog.isDebugEnabled())
{
myLog.debug( "received binary data:\n" + Conversions.byteArrayToHexDump( 
myByteArray ) );
}

Annother apporach is to write your own renderer. In this case you would have 
also to define an own class which transports the message and binary data 
through the log4j layers until it reaches your renderer.

Configuration:



Code:
if (myLog.isDebugEnabled())
{
BinaryWrapper wrap = new BinaryWrapper( "received binary data", myByteArray 
);
myLog.debug( wrap );
}

When log4j is about to convert the supplied Object to String, it will call your 
BinaryRenderer supplying your BinaryWrapper instance. Remember: the formal 
parameter of Logger.debug etc. is an Object and not a String. If no renderer 
for a particular class is configured, log4j just calls toString() of the 
supplied Object otherwise it calls the configured renderer.

Heri


> -Original Message-
> From: news [mailto:[EMAIL PROTECTED] Behalf Of teknokrat
> Sent: Monday, March 17, 2008 2:06 PM
> To: log4j-user@logging.apache.org
> Subject: [SPAM (Bayesain Analysis)] - How to log binary data 
> - Bayesian
> Filter detected spam
> 
> 
> I have a requirement to log raw binary data. This will be 
> mostly ASCII 
> characters but will contain non-displayable control 
> characters such as 
> \0, etc. My first thought was to write an appender by extending the 
> FileAppender class but I cannot see how to do this as I need 
> access to 
> an OutputStream and not a Writer. Does anyone have any good 
> ideas of how 
> this can be done witht he minimum of fuss in log4j?
> 
> cheers
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]