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

Ralph Goers commented on LOG4J2-3417:
-------------------------------------

[~ggregory] 

This was from our video chat today. Matt should have added a few more details. 
The JdbcAppender in Log4j 2 can accept ColumnConfigs and/or ColumnMappings such 
as:
{code:java}
    <JDBC name="databaseAppender" tableName="dbo.application_log">
      <DataSource jndiName="java:/comp/env/jdbc/LoggingDataSource" />
      <Column name="eventDate" isEventTimestamp="true" />
      <Column name="level" pattern="%level" />
      <Column name="logger" pattern="%logger" />
      <Column name="message" pattern="%message" />
      <Column name="exception" pattern="%ex{full}" />
    </JDBC> {code}
It is obvious that a query like:


{code:java}
insert into LogTable (Thread, Class, Message) values ("%t", "%c", "%m") {code}
could be converted to:
{code:java}
 <JDBC name="databaseAppender" tableName="LogTable">
   <ConnectionFactory class="net.example.db.ConnectionFactory" 
method="getDatabaseConnection" />
   <Column name="thread" pattern="%t" />
   <Column name="class" pattern="%c" />
   <Column name="message" pattern="%m" />
</JDBC>  {code}
Although it would be done using the Appender's Builder. 

So the task here is to create a JdbcAppenderBuilder that creates the Log4j 2 
JdbcAppender. So there is no requirement to use a prepared statement in the 
builder, only to build a proper Log4j 2 JdbcAppender.

 

> Create JDBC appender for compatibility with v1
> ----------------------------------------------
>
>                 Key: LOG4J2-3417
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3417
>             Project: Log4j 2
>          Issue Type: New Feature
>          Components: Appenders, Log4j 1.2 bridge
>            Reporter: Matt Sicker
>            Priority: Major
>
> Log4j 1 had a JDBC appender which made it fairly simple to set up an appender 
> to a database. While the old version doesn't work properly with modern 
> security practices, it shouldn't be too hard to parse the configured SQL 
> statement for pattern layout keys and extract them into a parameterized query.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to