[ 
https://issues.apache.org/jira/browse/LOG4J2-977?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gary Gregory updated LOG4J2-977:
--------------------------------
    Summary: Add maxLength parameter to Column element of JdbcAppender  (was: 
Add maxLength parameter to Column element of JDBCAppender)

> 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to