import org.apache.log4j.spi.*;
Finally I solved with just this trivial SMSLayout.
For me it's enough.
Bye
Davide
import org.apache.log4j.*;
import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;
/**
*
*/
public class SMSLayout extends Layout
{
/**
* two chars less, just in case for newline...
*/
private static final int MAX_SMS_LEN = 158;
private static final int HEADER_LEN = 160;
private SimpleDateFormat df = new SimpleDateFormat
("dd-MM-yyyy HH:mm:ss");
GregorianCalendar date = new GregorianCalendar();
/**
*
*/
public SMSLayout ()
{
date.setLenient(false);
}
/**
*
*/
public void activateOptions ()
{
// EMPTY
}
/**
*
* @param event
* @return
*/
public String format (LoggingEvent event)
{
StringBuffer buffer = new StringBuffer(MAX_SMS_LEN);
date.setTimeInMillis(event.timeStamp);
buffer.append(df.format(date.getTime()));
buffer.append(" ");
buffer.append(event.getLevel().toString());
buffer.append(" [");
buffer.append(event.getThreadName());
buffer.append("] - ");
String message = event.getRenderedMessage();
if (message.length() + buffer.length() > MAX_SMS_LEN)
{
message = message.substring(0, (MAX_SMS_LEN
- buffer.length()));
}
buffer.append(message);
buffer.append(LINE_SEP);
return buffer.toString();
}
/**
*
* @return
*/
public boolean ignoresThrowable ()
{
return false;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]