[jira] [Commented] (LOG4J2-424) JDBCAppender: Add support for data types other then String
[ https://issues.apache.org/jira/browse/LOG4J2-424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15797245#comment-15797245 ] Matt Sicker commented on LOG4J2-424: >From LOG4J2-1730, I added a ColumnMapping plugin for CassandraAppender. This >plugin could probably be reused to implement this feature request. > JDBCAppender: Add support for data types other then String > -- > > Key: LOG4J2-424 > URL: https://issues.apache.org/jira/browse/LOG4J2-424 > Project: Log4j 2 > Issue Type: Improvement > Components: Appenders >Affects Versions: 2.0-beta9 > Environment: All >Reporter: Tihomir Meščić >Assignee: Nick Williams > > I am using the JDBCAppender to log to a Postgresql database. I have a table > (log_entries) that's used for logging purposes. > One of the attributes is of type INTEGER. The attribute is something specific > for our application and we are using ThreadContext (MDC) to set the value of > the parameter. > Currently, log4j provides no support for integer type attributes in the > Column element of the JDBC appender configuration (the only types supported > are string (default), timestamp - isEventTimestamp flag and Clob - isClob > flag). > When using the default settings in the Column element of the JDBC appender, > log4j will create a prepared statement and try to set the value using the > Statement.setString() method. Of course, the JDBC driver throws an exception: > Caused by: org.postgresql.util.PSQLException: ERROR: column "mn_type_d" is of > type integer but expression is of type character varying > Hint: You will need to rewrite or cast the expression. > My appender configuration: > >username="xxx" password="xxx" /> > > > . > > > <-- this is of type integer in the DB but LOG4J tries to insert it as a > String --> > -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org
[jira] [Commented] (LOG4J2-424) JDBCAppender: Add support for data types other then String
[ https://issues.apache.org/jira/browse/LOG4J2-424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15591003#comment-15591003 ] Badreddine BENAIDJA commented on LOG4J2-424: I'll take a look > JDBCAppender: Add support for data types other then String > -- > > Key: LOG4J2-424 > URL: https://issues.apache.org/jira/browse/LOG4J2-424 > Project: Log4j 2 > Issue Type: Improvement > Components: Appenders >Affects Versions: 2.0-beta9 > Environment: All >Reporter: Tihomir Meščić >Assignee: Nick Williams > > I am using the JDBCAppender to log to a Postgresql database. I have a table > (log_entries) that's used for logging purposes. > One of the attributes is of type INTEGER. The attribute is something specific > for our application and we are using ThreadContext (MDC) to set the value of > the parameter. > Currently, log4j provides no support for integer type attributes in the > Column element of the JDBC appender configuration (the only types supported > are string (default), timestamp - isEventTimestamp flag and Clob - isClob > flag). > When using the default settings in the Column element of the JDBC appender, > log4j will create a prepared statement and try to set the value using the > Statement.setString() method. Of course, the JDBC driver throws an exception: > Caused by: org.postgresql.util.PSQLException: ERROR: column "mn_type_d" is of > type integer but expression is of type character varying > Hint: You will need to rewrite or cast the expression. > My appender configuration: > >username="xxx" password="xxx" /> > > > . > > > <-- this is of type integer in the DB but LOG4J tries to insert it as a > String --> > -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org
[jira] [Commented] (LOG4J2-424) JDBCAppender: Add support for data types other then String
[ https://issues.apache.org/jira/browse/LOG4J2-424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15588849#comment-15588849 ] Matt Sicker commented on LOG4J2-424: Have you looked at the JPAAppender? > JDBCAppender: Add support for data types other then String > -- > > Key: LOG4J2-424 > URL: https://issues.apache.org/jira/browse/LOG4J2-424 > Project: Log4j 2 > Issue Type: Improvement > Components: Appenders >Affects Versions: 2.0-beta9 > Environment: All >Reporter: Tihomir Meščić >Assignee: Nick Williams > > I am using the JDBCAppender to log to a Postgresql database. I have a table > (log_entries) that's used for logging purposes. > One of the attributes is of type INTEGER. The attribute is something specific > for our application and we are using ThreadContext (MDC) to set the value of > the parameter. > Currently, log4j provides no support for integer type attributes in the > Column element of the JDBC appender configuration (the only types supported > are string (default), timestamp - isEventTimestamp flag and Clob - isClob > flag). > When using the default settings in the Column element of the JDBC appender, > log4j will create a prepared statement and try to set the value using the > Statement.setString() method. Of course, the JDBC driver throws an exception: > Caused by: org.postgresql.util.PSQLException: ERROR: column "mn_type_d" is of > type integer but expression is of type character varying > Hint: You will need to rewrite or cast the expression. > My appender configuration: > >username="xxx" password="xxx" /> > > > . > > > <-- this is of type integer in the DB but LOG4J tries to insert it as a > String --> > -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org
[jira] [Commented] (LOG4J2-424) JDBCAppender: Add support for data types other then String
[ https://issues.apache.org/jira/browse/LOG4J2-424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15588347#comment-15588347 ] Badreddine BENAIDJA commented on LOG4J2-424: No ! Since the SQL query is generated by org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager by calling PreparedStatement.setString() > JDBCAppender: Add support for data types other then String > -- > > Key: LOG4J2-424 > URL: https://issues.apache.org/jira/browse/LOG4J2-424 > Project: Log4j 2 > Issue Type: Improvement > Components: Appenders >Affects Versions: 2.0-beta9 > Environment: All >Reporter: Tihomir Meščić >Assignee: Nick Williams > > I am using the JDBCAppender to log to a Postgresql database. I have a table > (log_entries) that's used for logging purposes. > One of the attributes is of type INTEGER. The attribute is something specific > for our application and we are using ThreadContext (MDC) to set the value of > the parameter. > Currently, log4j provides no support for integer type attributes in the > Column element of the JDBC appender configuration (the only types supported > are string (default), timestamp - isEventTimestamp flag and Clob - isClob > flag). > When using the default settings in the Column element of the JDBC appender, > log4j will create a prepared statement and try to set the value using the > Statement.setString() method. Of course, the JDBC driver throws an exception: > Caused by: org.postgresql.util.PSQLException: ERROR: column "mn_type_d" is of > type integer but expression is of type character varying > Hint: You will need to rewrite or cast the expression. > My appender configuration: > >username="xxx" password="xxx" /> > > > . > > > <-- this is of type integer in the DB but LOG4J tries to insert it as a > String --> > -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org
[jira] [Commented] (LOG4J2-424) JDBCAppender: Add support for data types other then String
[ https://issues.apache.org/jira/browse/LOG4J2-424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15585969#comment-15585969 ] Remko Popma commented on LOG4J2-424: Potentially yes, but... The good news is that while the ThreadContext facade only lets you put String values, since 2.7 the underlying data structure accepts Object values. The question then becomes how do applications gain access to the underlying data structure. Unfortunately we haven't really thought this part through yet. The ThreadContextMap implementation can be replaced via a system property. This allows applications to switch to a garbagefree implementation or a custom implementation etc, but putting values still goes through the ThreadContext facade, which doesn't give the application access to any new feature provided by this ThreadContextMap implementation... ThreadContextAccess allows access to the internals (this is how the ContextInjector in Log4j core accesses the underlying ThreadContextMap implementation). This will work in 2.7 but is documented as "not for application use". It may go away in future versions if we find a better way, so be aware that if you rely on ThreadContextAccess, your code may break with any Log4j upgrade. We need to think about how we can extend the ThreadContext facade or allow custom facades or provide some other way for applications to access any additional API that their ThreadContextMap implementation provides. > JDBCAppender: Add support for data types other then String > -- > > Key: LOG4J2-424 > URL: https://issues.apache.org/jira/browse/LOG4J2-424 > Project: Log4j 2 > Issue Type: Improvement > Components: Appenders >Affects Versions: 2.0-beta9 > Environment: All >Reporter: Tihomir Meščić >Assignee: Nick Williams > > I am using the JDBCAppender to log to a Postgresql database. I have a table > (log_entries) that's used for logging purposes. > One of the attributes is of type INTEGER. The attribute is something specific > for our application and we are using ThreadContext (MDC) to set the value of > the parameter. > Currently, log4j provides no support for integer type attributes in the > Column element of the JDBC appender configuration (the only types supported > are string (default), timestamp - isEventTimestamp flag and Clob - isClob > flag). > When using the default settings in the Column element of the JDBC appender, > log4j will create a prepared statement and try to set the value using the > Statement.setString() method. Of course, the JDBC driver throws an exception: > Caused by: org.postgresql.util.PSQLException: ERROR: column "mn_type_d" is of > type integer but expression is of type character varying > Hint: You will need to rewrite or cast the expression. > My appender configuration: > >username="xxx" password="xxx" /> > > > . > > > <-- this is of type integer in the DB but LOG4J tries to insert it as a > String --> > -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org
[jira] [Commented] (LOG4J2-424) JDBCAppender: Add support for data types other then String
[ https://issues.apache.org/jira/browse/LOG4J2-424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15585789#comment-15585789 ] Gary Gregory commented on LOG4J2-424: - Note that this is only a blocker if the JDBC driver you are using is not smart enough to do type conversion. > JDBCAppender: Add support for data types other then String > -- > > Key: LOG4J2-424 > URL: https://issues.apache.org/jira/browse/LOG4J2-424 > Project: Log4j 2 > Issue Type: Improvement > Components: Appenders >Affects Versions: 2.0-beta9 > Environment: All >Reporter: Tihomir Meščić >Assignee: Nick Williams > > I am using the JDBCAppender to log to a Postgresql database. I have a table > (log_entries) that's used for logging purposes. > One of the attributes is of type INTEGER. The attribute is something specific > for our application and we are using ThreadContext (MDC) to set the value of > the parameter. > Currently, log4j provides no support for integer type attributes in the > Column element of the JDBC appender configuration (the only types supported > are string (default), timestamp - isEventTimestamp flag and Clob - isClob > flag). > When using the default settings in the Column element of the JDBC appender, > log4j will create a prepared statement and try to set the value using the > Statement.setString() method. Of course, the JDBC driver throws an exception: > Caused by: org.postgresql.util.PSQLException: ERROR: column "mn_type_d" is of > type integer but expression is of type character varying > Hint: You will need to rewrite or cast the expression. > My appender configuration: > >username="xxx" password="xxx" /> > > > . > > > <-- this is of type integer in the DB but LOG4J tries to insert it as a > String --> > -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org
[jira] [Commented] (LOG4J2-424) JDBCAppender: Add support for data types other then String
[ https://issues.apache.org/jira/browse/LOG4J2-424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15585758#comment-15585758 ] Mikael Ståldal commented on LOG4J2-424: --- Yes, sort of. Log4j 2.7 have a new typed version of Thread Context. > JDBCAppender: Add support for data types other then String > -- > > Key: LOG4J2-424 > URL: https://issues.apache.org/jira/browse/LOG4J2-424 > Project: Log4j 2 > Issue Type: Improvement > Components: Appenders >Affects Versions: 2.0-beta9 > Environment: All >Reporter: Tihomir Meščić >Assignee: Nick Williams > > I am using the JDBCAppender to log to a Postgresql database. I have a table > (log_entries) that's used for logging purposes. > One of the attributes is of type INTEGER. The attribute is something specific > for our application and we are using ThreadContext (MDC) to set the value of > the parameter. > Currently, log4j provides no support for integer type attributes in the > Column element of the JDBC appender configuration (the only types supported > are string (default), timestamp - isEventTimestamp flag and Clob - isClob > flag). > When using the default settings in the Column element of the JDBC appender, > log4j will create a prepared statement and try to set the value using the > Statement.setString() method. Of course, the JDBC driver throws an exception: > Caused by: org.postgresql.util.PSQLException: ERROR: column "mn_type_d" is of > type integer but expression is of type character varying > Hint: You will need to rewrite or cast the expression. > My appender configuration: > >username="xxx" password="xxx" /> > > > . > > > <-- this is of type integer in the DB but LOG4J tries to insert it as a > String --> > -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org
[jira] [Commented] (LOG4J2-424) JDBCAppender: Add support for data types other then String
[ https://issues.apache.org/jira/browse/LOG4J2-424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15585747#comment-15585747 ] Badreddine BENAIDJA commented on LOG4J2-424: [~mikael.stal...@home.se] you mean Thread Context ? > JDBCAppender: Add support for data types other then String > -- > > Key: LOG4J2-424 > URL: https://issues.apache.org/jira/browse/LOG4J2-424 > Project: Log4j 2 > Issue Type: Improvement > Components: Appenders >Affects Versions: 2.0-beta9 > Environment: All >Reporter: Tihomir Meščić >Assignee: Nick Williams > > I am using the JDBCAppender to log to a Postgresql database. I have a table > (log_entries) that's used for logging purposes. > One of the attributes is of type INTEGER. The attribute is something specific > for our application and we are using ThreadContext (MDC) to set the value of > the parameter. > Currently, log4j provides no support for integer type attributes in the > Column element of the JDBC appender configuration (the only types supported > are string (default), timestamp - isEventTimestamp flag and Clob - isClob > flag). > When using the default settings in the Column element of the JDBC appender, > log4j will create a prepared statement and try to set the value using the > Statement.setString() method. Of course, the JDBC driver throws an exception: > Caused by: org.postgresql.util.PSQLException: ERROR: column "mn_type_d" is of > type integer but expression is of type character varying > Hint: You will need to rewrite or cast the expression. > My appender configuration: > >username="xxx" password="xxx" /> > > > . > > > <-- this is of type integer in the DB but LOG4J tries to insert it as a > String --> > -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org
[jira] [Commented] (LOG4J2-424) JDBCAppender: Add support for data types other then String
[ https://issues.apache.org/jira/browse/LOG4J2-424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15585717#comment-15585717 ] Mikael Ståldal commented on LOG4J2-424: --- [~rem...@yahoo.com], can we use the new ContextData for this? > JDBCAppender: Add support for data types other then String > -- > > Key: LOG4J2-424 > URL: https://issues.apache.org/jira/browse/LOG4J2-424 > Project: Log4j 2 > Issue Type: Improvement > Components: Appenders >Affects Versions: 2.0-beta9 > Environment: All >Reporter: Tihomir Meščić >Assignee: Nick Williams > > I am using the JDBCAppender to log to a Postgresql database. I have a table > (log_entries) that's used for logging purposes. > One of the attributes is of type INTEGER. The attribute is something specific > for our application and we are using ThreadContext (MDC) to set the value of > the parameter. > Currently, log4j provides no support for integer type attributes in the > Column element of the JDBC appender configuration (the only types supported > are string (default), timestamp - isEventTimestamp flag and Clob - isClob > flag). > When using the default settings in the Column element of the JDBC appender, > log4j will create a prepared statement and try to set the value using the > Statement.setString() method. Of course, the JDBC driver throws an exception: > Caused by: org.postgresql.util.PSQLException: ERROR: column "mn_type_d" is of > type integer but expression is of type character varying > Hint: You will need to rewrite or cast the expression. > My appender configuration: > >username="xxx" password="xxx" /> > > > . > > > <-- this is of type integer in the DB but LOG4J tries to insert it as a > String --> > -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org
[jira] [Commented] (LOG4J2-424) JDBCAppender: Add support for data types other then String
[ https://issues.apache.org/jira/browse/LOG4J2-424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15585705#comment-15585705 ] Badreddine BENAIDJA commented on LOG4J2-424: For me it's a *BLOCKER* Issue since there is no way to store values expect changing the DB Schema ! Suggestion : Add a attribute type in the object org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager.Column Switch on it and call the right method of java.sql.PreparedStatement setInt(...) setFloat(...) ... etc > JDBCAppender: Add support for data types other then String > -- > > Key: LOG4J2-424 > URL: https://issues.apache.org/jira/browse/LOG4J2-424 > Project: Log4j 2 > Issue Type: Improvement > Components: Appenders >Affects Versions: 2.0-beta9 > Environment: All >Reporter: Tihomir Meščić >Assignee: Nick Williams > > I am using the JDBCAppender to log to a Postgresql database. I have a table > (log_entries) that's used for logging purposes. > One of the attributes is of type INTEGER. The attribute is something specific > for our application and we are using ThreadContext (MDC) to set the value of > the parameter. > Currently, log4j provides no support for integer type attributes in the > Column element of the JDBC appender configuration (the only types supported > are string (default), timestamp - isEventTimestamp flag and Clob - isClob > flag). > When using the default settings in the Column element of the JDBC appender, > log4j will create a prepared statement and try to set the value using the > Statement.setString() method. Of course, the JDBC driver throws an exception: > Caused by: org.postgresql.util.PSQLException: ERROR: column "mn_type_d" is of > type integer but expression is of type character varying > Hint: You will need to rewrite or cast the expression. > My appender configuration: > >username="xxx" password="xxx" /> > > > . > > > <-- this is of type integer in the DB but LOG4J tries to insert it as a > String --> > -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org
[jira] [Commented] (LOG4J2-424) JDBCAppender: Add support for data types other then String
[ https://issues.apache.org/jira/browse/LOG4J2-424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14071927#comment-14071927 ] Matt Sicker commented on LOG4J2-424: The type conversion only works when you use setObject instead of setString/setClob like we are doing. In a related matter, I'd like to see an XML layout that returns a javax.xml.transform.Result instead of a String for insertion as an SQLXML type. Sadly, Result does not appear to be Serializable, so a dedicated Layout wouldn't work. > JDBCAppender: Add support for data types other then String > -- > > Key: LOG4J2-424 > URL: https://issues.apache.org/jira/browse/LOG4J2-424 > Project: Log4j 2 > Issue Type: Improvement > Components: Appenders >Affects Versions: 2.0-beta9 > Environment: All >Reporter: Tihomir Meščić >Assignee: Nick Williams > > I am using the JDBCAppender to log to a Postgresql database. I have a table > (log_entries) that's used for logging purposes. > One of the attributes is of type INTEGER. The attribute is something specific > for our application and we are using ThreadContext (MDC) to set the value of > the parameter. > Currently, log4j provides no support for integer type attributes in the > Column element of the JDBC appender configuration (the only types supported > are string (default), timestamp - isEventTimestamp flag and Clob - isClob > flag). > When using the default settings in the Column element of the JDBC appender, > log4j will create a prepared statement and try to set the value using the > Statement.setString() method. Of course, the JDBC driver throws an exception: > Caused by: org.postgresql.util.PSQLException: ERROR: column "mn_type_d" is of > type integer but expression is of type character varying > Hint: You will need to rewrite or cast the expression. > My appender configuration: > >username="xxx" password="xxx" /> > > > . > > > <-- this is of type integer in the DB but LOG4J tries to insert it as a > String --> > -- This message was sent by Atlassian JIRA (v6.2#6252) - To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org
[jira] [Commented] (LOG4J2-424) JDBCAppender: Add support for data types other then String
[ https://issues.apache.org/jira/browse/LOG4J2-424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14071914#comment-14071914 ] Gary Gregory commented on LOG4J2-424: - Let's be careful here. There are JDBC drivers out there that do type conversions on their own. Perhaps we should state in the docs that you should only do this after you see your driver/database fail. Would a simple way to handle this be to let the config specify which JDBC data type to use for a given column and then do some conversion magic? For the first pass, I would not refactor TypeConverter to see what a JDBC appender solution looks like. Then I would consider refactoring so we do not create some overly complex framework if all we need is some simple JDBC type conversion code. But that's just me, and I'm doing it now :-) > JDBCAppender: Add support for data types other then String > -- > > Key: LOG4J2-424 > URL: https://issues.apache.org/jira/browse/LOG4J2-424 > Project: Log4j 2 > Issue Type: Improvement > Components: Appenders >Affects Versions: 2.0-beta9 > Environment: All >Reporter: Tihomir Meščić >Assignee: Nick Williams > > I am using the JDBCAppender to log to a Postgresql database. I have a table > (log_entries) that's used for logging purposes. > One of the attributes is of type INTEGER. The attribute is something specific > for our application and we are using ThreadContext (MDC) to set the value of > the parameter. > Currently, log4j provides no support for integer type attributes in the > Column element of the JDBC appender configuration (the only types supported > are string (default), timestamp - isEventTimestamp flag and Clob - isClob > flag). > When using the default settings in the Column element of the JDBC appender, > log4j will create a prepared statement and try to set the value using the > Statement.setString() method. Of course, the JDBC driver throws an exception: > Caused by: org.postgresql.util.PSQLException: ERROR: column "mn_type_d" is of > type integer but expression is of type character varying > Hint: You will need to rewrite or cast the expression. > My appender configuration: > >username="xxx" password="xxx" /> > > > . > > > <-- this is of type integer in the DB but LOG4J tries to insert it as a > String --> > -- This message was sent by Atlassian JIRA (v6.2#6252) - To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org
[jira] [Commented] (LOG4J2-424) JDBCAppender: Add support for data types other then String
[ https://issues.apache.org/jira/browse/LOG4J2-424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14071899#comment-14071899 ] Matt Sicker commented on LOG4J2-424: There's a couple ways we can go about adding this feature. We can use JDBC metadata to do some "automatic" type conversion. We can add another attribute to specify the type, but this would also require the type conversion. Re-using the TypeConverter code from plugin configuration, this shouldn't be too difficult. However, a logical next step would be making the TypeConverters properly extensible. As a related addition, an SQLXML column type could allow for use of the XmlLayout as well. This would most likely require additions to the Column configuration element. > JDBCAppender: Add support for data types other then String > -- > > Key: LOG4J2-424 > URL: https://issues.apache.org/jira/browse/LOG4J2-424 > Project: Log4j 2 > Issue Type: Improvement > Components: Appenders >Affects Versions: 2.0-beta9 > Environment: All >Reporter: Tihomir Meščić >Assignee: Nick Williams > > I am using the JDBCAppender to log to a Postgresql database. I have a table > (log_entries) that's used for logging purposes. > One of the attributes is of type INTEGER. The attribute is something specific > for our application and we are using ThreadContext (MDC) to set the value of > the parameter. > Currently, log4j provides no support for integer type attributes in the > Column element of the JDBC appender configuration (the only types supported > are string (default), timestamp - isEventTimestamp flag and Clob - isClob > flag). > When using the default settings in the Column element of the JDBC appender, > log4j will create a prepared statement and try to set the value using the > Statement.setString() method. Of course, the JDBC driver throws an exception: > Caused by: org.postgresql.util.PSQLException: ERROR: column "mn_type_d" is of > type integer but expression is of type character varying > Hint: You will need to rewrite or cast the expression. > My appender configuration: > >username="xxx" password="xxx" /> > > > . > > > <-- this is of type integer in the DB but LOG4J tries to insert it as a > String --> > -- This message was sent by Atlassian JIRA (v6.2#6252) - To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org
[jira] [Commented] (LOG4J2-424) JDBCAppender: Add support for data types other then String
[ https://issues.apache.org/jira/browse/LOG4J2-424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13863866#comment-13863866 ] Matt Sicker commented on LOG4J2-424: Are you using Hibernate? If so, why not just use the JPAAppender? But I like the idea of supporting some other column types. > JDBCAppender: Add support for data types other then String > -- > > Key: LOG4J2-424 > URL: https://issues.apache.org/jira/browse/LOG4J2-424 > Project: Log4j 2 > Issue Type: Improvement > Components: Appenders >Affects Versions: 2.0-beta9 > Environment: All >Reporter: Tihomir Meščić >Assignee: Nick Williams > > I am using the JDBCAppender to log to a Postgresql database. I have a table > (log_entries) that's used for logging purposes. > One of the attributes is of type INTEGER. The attribute is something specific > for our application and we are using ThreadContext (MDC) to set the value of > the parameter. > Currently, log4j provides no support for integer type attributes in the > Column element of the JDBC appender configuration (the only types supported > are string (default), timestamp - isEventTimestamp flag and Clob - isClob > flag). > When using the default settings in the Column element of the JDBC appender, > log4j will create a prepared statement and try to set the value using the > Statement.setString() method. Of course, the JDBC driver throws an exception: > Caused by: org.postgresql.util.PSQLException: ERROR: column "mn_type_d" is of > type integer but expression is of type character varying > Hint: You will need to rewrite or cast the expression. > My appender configuration: > >username="xxx" password="xxx" /> > > > . > > > <-- this is of type integer in the DB but LOG4J tries to insert it as a > String --> > -- This message was sent by Atlassian JIRA (v6.1.5#6160) - To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org