DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG· RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=39691>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND· INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39691 Summary: DBAppender doesn't log long events Product: Log4j Version: 1.3alpha Platform: Other OS/Version: Windows XP Status: NEW Severity: normal Priority: P2 Component: Appender AssignedTo: [email protected] ReportedBy: [EMAIL PROTECTED] DBAppender contains scripts for creating tables with columns with maximal length - for example renderedmessage is VARCHAR2(4000). However while appending records length is not controlled, so if I try to append long log database throws exception and nothing is logged. The same problem as with rendered message is with writing stack trace. So I extended your classes with mine, although I think this functionality should be in base classes. ############## Repaired Log4JTrimmedLoggingEvent ################ package cz.corpus.f1.commons.log; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.spi.LocationInfo; import org.apache.log4j.spi.LoggingEvent; import org.apache.log4j.spi.ThrowableInformation; import java.util.Hashtable; import java.util.Map; import java.util.Set; /** * @author Jan Novotný */ public class Log4JTrimmedLoggingEvent extends LoggingEvent { LoggingEvent original; public Log4JTrimmedLoggingEvent(LoggingEvent original) { this.original = original; } public boolean equals(Object rObject) { return original.equals(rObject); } public String getFQNOfLoggerClass() { return original.getFQNOfLoggerClass(); } public Level getLevel() { return original.getLevel(); } public LocationInfo getLocationInformation() { return original.getLocationInformation(); } public Logger getLogger() { return original.getLogger(); } public String getLoggerName() { return original.getLoggerName(); } public Object getMDC(final String key) { return original.getMDC(key); } public void getMDCCopy() { original.getMDCCopy(); } public Object getMessage() { return original.getMessage(); } public String getNDC() { return original.getNDC(); } public Map getProperties() { return original.getProperties(); } public String getProperty(String key) { return original.getProperty(key); } public Set getPropertyKeySet() { return original.getPropertyKeySet(); } public String getRenderedMessage() { String origMsg = original.getRenderedMessage(); if(origMsg.length() > 3800){ return origMsg.substring(0, 3800) + " ... msg too long - trimed " + (origMsg.length() - 3800) + " characters"; } return origMsg; } public long getSequenceNumber() { return original.getSequenceNumber(); } public String getThreadName() { return original.getThreadName(); } public ThrowableInformation getThrowableInformation() { return new Log4JTrimmedThrowableInformation(original.getThrowableInformation()); } public String[] getThrowableStrRep() { return new Log4JTrimmedThrowableInformation(original.getThrowableInformation()).getThrowableStrRep(); } public long getTimeStamp() { return original.getTimeStamp(); } public int hashCode() { return original.hashCode(); } public void initializeProperties() { original.initializeProperties(); } public boolean locationInformationExists() { return original.locationInformationExists(); } public void prepareForDeferredProcessing() { original.prepareForDeferredProcessing(); } public void setFQNOfLoggerClass(String fqnOfLoggerClass) { original.setFQNOfLoggerClass(fqnOfLoggerClass); } public void setLevel(Level level) { original.setLevel(level); } public void setLocationInformation(LocationInfo li) { original.setLocationInformation(li); } public void setLogger(Logger logger) { original.setLogger(logger); } public void setLoggerName(String loggerName) throws IllegalStateException { original.setLoggerName(loggerName); } public void setMessage(Object message) { original.setMessage(message); } public void setNDC(String ndcString) { original.setNDC(ndcString); } public void setProperties(Hashtable properties) { original.setProperties(properties); } public void setProperty(String key, String value) { original.setProperty(key, value); } public void setRenderedMessage(String renderedMessage) throws IllegalStateException { original.setRenderedMessage(renderedMessage); } public void setSequenceNumber(long sequenceNumber) { original.setSequenceNumber(sequenceNumber); } public void setThreadName(String threadName) throws IllegalStateException { original.setThreadName(threadName); } public void setThrowableInformation(ThrowableInformation ti) { original.setThrowableInformation(ti); } public void setTimeStamp(long timeStamp) { original.setTimeStamp(timeStamp); } } ############## Repaired Log4JTrimmedThrowableInformation ############### package cz.corpus.f1.commons.log; import org.apache.log4j.spi.ThrowableInformation; /** * @author Jan Novotný */ public class Log4JTrimmedThrowableInformation extends ThrowableInformation { ThrowableInformation original; public Log4JTrimmedThrowableInformation(ThrowableInformation ti) { super(ti.getThrowableStrRep()); original = ti; } public boolean equals(Object o) { return original.equals(o); } public Throwable getThrowable() { return original.getThrowable(); } public String[] getThrowableStrRep() { String[] throwableStrRep = original.getThrowableStrRep(); String[] result = new String[throwableStrRep.length]; for (int i = 0; i < throwableStrRep.length; i++) { String msg = throwableStrRep[i]; int lng = msg.length(); if (msg != null && lng > 254) { msg = "..." + msg.substring(lng - 230, lng); } result[i] = msg; } return throwableStrRep; } } -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
