tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jack Bounds <Jack.Bou...@googlemail.com>
Subject Re: log4j 2 : JDBC Appender
Date Wed, 23 Sep 2015 05:50:58 GMT
Hi Romain,

many thx for the help, I appreciate that!

I am going for tomee.xml and openejb:Resource/jdbc/LoggingDB, just as you
recommended.
Using the Resource node as it was, resulted in a failure (listed at the very
end).

After moving some of the attributes to the node body (all these
configuration properties) and renaming the node attribute 'factory' to
'factory-name' it ... wow! ... it worked just fine.
The jndi name is "openejb:Resource/jdbc/LoggingDB".

Here comes a short listing of my working log4j2 pooled JDBC appender example
for sake of completeness and interested fellow TomEE users (and yes, I am
using Maven now):


...\tomee-plus-1.7.2\conf\tomee.xml:
<Resource id="jdbc/LoggingDB"
               type="javax.sql.DataSource"
               factory-name="org.apache.tomcat.jdbc.pool.DataSourceFactory">
      auth      Container
      maxActive 100
      maxIdle   30
      maxWait   10000
      username  valid-user-name
      password  valid-pwd
      driverClassName com.mysql.jdbc.Driver
      url jdbc:mysql://localhost/Logging
  </Resource>


...\src\main\resources\log4j2.xml:
<Appenders>
<JDBC name="databaseAppender" tableName="logging">
            <DataSource jndiName="openejb:Resource/jdbc/LoggingDB" />
            <Column name="EVENT_DATE" isEventTimestamp="true" />
            <Column name="LEVEL" pattern="%level" />
            <Column name="LOGGER" pattern="%logger" />
            <Column name="MSG" pattern="%message" />
            <Column name="THROWABLE" pattern="%ex{full}" />
</JDBC>
</Appenders>


...\mis\pom.xml:
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.3.1-SNAPSHOT</version>
</dependency>
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.3.1-SNAPSHOT</version>
</dependency>
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.36</version>
</dependency>


initial tomcat output:
org.apache.openejb.OpenEJBException: Unable to read OpenEJB configuration
file at
C:\Users\IVack\.IntelliJIdea14\system\tomcat\Unnamed_mis\conf\tomee.xml:
Unsupported Attribute(s): name, auth, factory, maxActive, maxIdle, maxWait,
username, password, driverClassName, url.
Supported Attributes are: type, jar, provider, id, class-name, constructor,
factory-name, classpath, jndi, aliases, properties-provider.  If the setting
is a configuration property it must be placed inside the element body.



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/log4j-2-JDBC-Appender-tp4676313p4676324.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Mime
View raw message