You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by sw...@apache.org on 2023/05/03 00:16:53 UTC

[logging-log4cxx] 02/02: ODBCAppender should not use the message as an SQL statement

This is an automated email from the ASF dual-hosted git repository.

swebb2066 pushed a commit to branch odbc_appender_regression
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git

commit 0bdf9edae584e5c94b887c977c3d4e092a1a84e4
Author: Stephen Webb <sw...@gmail.com>
AuthorDate: Wed May 3 10:16:26 2023 +1000

    ODBCAppender should not use the message as an SQL statement
---
 src/main/cpp/odbcappender.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/main/cpp/odbcappender.cpp b/src/main/cpp/odbcappender.cpp
index b5202c6b..49993fd0 100644
--- a/src/main/cpp/odbcappender.cpp
+++ b/src/main/cpp/odbcappender.cpp
@@ -249,7 +249,10 @@ void ODBCAppender::append(const spi::LoggingEventPtr& event, log4cxx::helpers::P
 LogString ODBCAppender::getLogStatement(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p) const
 {
 	LogString sbuf;
-	getLayout()->format(sbuf, event, p);
+	if (auto l = getLayout())
+		l->format(sbuf, event, p);
+	else
+		LogLog::error(LOG4CXX_STR("A SQL statement must be provided to ODBCAppender"));
 	return sbuf;
 }