Details
-
New Feature
-
Status: Closed
-
TBD
-
Resolution: Fixed
-
None
-
None
-
None
-
Undetermined
Description
Recently, I was trying to introduce some new logging for log4j which would log certain messages to a log table in the OpenMRS database rather than (or in addition to) the console or to a file.
log4j / log4j2 provide an out-of-the-box appender option for this, called the JDBC Appender, as documented here:
https://logging.apache.org/log4j/2.x/manual/appenders.html#JDBCAppender
One of the (strong) recommendations made for this appender is (quoted from the above page):
The JDBC Appender writes log events to a relational database table using standard JDBC. It can be configured to obtain JDBC connections using a JNDI DataSource or a custom factory method. The JDBC Appender...must be backed by a connection pool. Otherwise, logging performance will suffer greatly.
I have been able to get things working fine in development using a factory method that is not backed by a connection pool, using the existing org.openmrs.util.DatabaseUpdater.getConnection() static method that simply creates a new connection based on information in the runtime properties each time. That configuration looks like this in log4j2.xml:
<ConnectionFactory class="org.openmrs.util.DatabaseUpdater" method="getConnection" />
What I'd like is to have an equivalent factory method to use but which is backed by the DataSource used by Hibernate (which is a C3PO-based Pooling Data Source).
Note: I originally tried adding such a thing to my module, but the nature and timing of log4j initialization resulted in the classes defined in my module not being found.
dkayiwa / ibacher / mogoodrich any thoughts on concerns on this?