You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Gary Gregory (JIRA)" <ji...@apache.org> on 2015/03/18 01:41:38 UTC
[jira] [Updated] (LOG4J2-977) Add maxLength parameter to Column
element of JDBCAppender
[ https://issues.apache.org/jira/browse/LOG4J2-977?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gary Gregory updated LOG4J2-977:
--------------------------------
Description:
For a Column element within the JDBCAppender, add a maxLength parameter to truncate the value to a maxLength. This will help prevent exceptions when inserting rows into the database and the length of a string is greater than the size of a column.
For instance, the following would limit the value to 4000 characters by truncating message if the length is greater than 4000 characters.
{code:xml}
<Column name="message" pattern="%message" isUnicode="false" maxLength="4000"/>
{code}
Note: In log4j 1.x we solved this problem by coding a custom class that implemented the interface JDBCColumnHandler, but Log4j2 does not offer this interface:
{code:java}
public class MessageColumnHandler implements JDBCColumnHandler {
@Override
public Object getObject( final LoggingEvent pLoggingEvent, final String s, final String s2 ) throws Exception {
return StringUtils.abbreviate( "intercepted: "
+ pLoggingEvent.getRenderedMessage()
, 4000 );
}
}
{code}
was:
For a Column element within the JDBCAppender, add a maxLength parameter to truncate the value to a maxLength. This will help prevent exceptions when inserting rows into the database and the length of a string is greater than the size of a column.
For instance, the following would limit the value to 4000 characters by truncating message if the length is greater than 4000 characters.
<Column name="message" pattern="%message" isUnicode="false" maxLength="4000"/>
Note: In log4j 1.x we solved this problem by coding a custom class that implemented the interface JDBCColumnHandler, but Log4j2 does not offer this interface:
public class MessageColumnHandler implements JDBCColumnHandler {
@Override
public Object getObject( final LoggingEvent pLoggingEvent, final String s, final String s2 ) throws Exception {
return StringUtils.abbreviate( "intercepted: "
+ pLoggingEvent.getRenderedMessage()
, 4000 );
}
}
> Add maxLength parameter to Column element of JDBCAppender
> ---------------------------------------------------------
>
> Key: LOG4J2-977
> URL: https://issues.apache.org/jira/browse/LOG4J2-977
> Project: Log4j 2
> Issue Type: Improvement
> Components: Appenders
> Affects Versions: 2.1, 2.2
> Reporter: Jeff Snow
>
> For a Column element within the JDBCAppender, add a maxLength parameter to truncate the value to a maxLength. This will help prevent exceptions when inserting rows into the database and the length of a string is greater than the size of a column.
> For instance, the following would limit the value to 4000 characters by truncating message if the length is greater than 4000 characters.
> {code:xml}
> <Column name="message" pattern="%message" isUnicode="false" maxLength="4000"/>
> {code}
> Note: In log4j 1.x we solved this problem by coding a custom class that implemented the interface JDBCColumnHandler, but Log4j2 does not offer this interface:
> {code:java}
> public class MessageColumnHandler implements JDBCColumnHandler {
> @Override
> public Object getObject( final LoggingEvent pLoggingEvent, final String s, final String s2 ) throws Exception {
> return StringUtils.abbreviate( "intercepted: "
> + pLoggingEvent.getRenderedMessage()
> , 4000 );
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org