[ 
https://issues.apache.org/jira/browse/LOG4J2-977?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14366441#comment-14366441
 ] 

Ralph Goers commented on LOG4J2-977:
------------------------------------

The FlumePersistentAppender uses the PluginManager to locate and install a 
"KeyProvider" for use in providing the secret key for encryption. I would 
suggest that it would be possible to enhance the JdbcAppender in the same way 
to provide the column handler you would really like, instead of just adding the 
max length as a parameter.  To do this a new attribute such as "columnHandler" 
would be added which would be the name of the ColumnHandler plugin that should 
be used for this Appender.

> 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