You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Jack Bounds <Ja...@googlemail.com> on 2015/09/22 11:28:06 UTC
log4j 2 : JDBC Appender
Hi TomEE guys!
I am using log4j2 and like to add a mysql JDBC pooled appender to my
log4j2.xml configuration.
I failed to do so, and instead of reporting all the stupid stuff I tried the
last days, I got three basic questions.
1: Where is a good place to add a resource as the following?
<Resource name="jdbc/LoggingDB" auth="Container"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
type="javax.sql.DataSource" maxActive="100" maxIdle="30"
maxWait="10000"
username="some-name" password="some-pwd"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/test" />
2: What would the jndiName attribute of DataSource in log4j2.xml look like
then?
<Appenders>
<JDBC name="databaseAppender" tableName="logging">
<DataSource jndiName="what-is-the-valid-jndi-name-of-LoggingDB"
/>
<Column name="..." />
<Column name="..." />
</JDBC>
</Appenders>
3: Do I need any further configuration in another file (like
WEB_INF/web.xml, WEB_INF/resources.xml) ?
I am running TomEE tomee-plus-1.7.2.
I would appreciate any help,
BR Jack
--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/log4j-2-JDBC-Appender-tp4676313.html
Sent from the TomEE Users mailing list archive at Nabble.com.
Re: log4j 2 : JDBC Appender
Posted by Jack Bounds <Ja...@googlemail.com>.
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.
Re: log4j 2 : JDBC Appender
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi
Le 22 sept. 2015 02:36, "Jack Bounds" <Ja...@googlemail.com> a écrit :
>
> Hi TomEE guys!
>
> I am using log4j2 and like to add a mysql JDBC pooled appender to my
> log4j2.xml configuration.
> I failed to do so, and instead of reporting all the stupid stuff I tried
the
> last days, I got three basic questions.
>
> 1: Where is a good place to add a resource as the following?
>
> <Resource name="jdbc/LoggingDB" auth="Container"
> factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
> type="javax.sql.DataSource" maxActive="100" maxIdle="30"
> maxWait="10000"
> username="some-name" password="some-pwd"
> driverClassName="com.mysql.jdbc.Driver"
> url="jdbc:mysql://localhost/test" />
>
Looks like a tomcat resource so context.xml or server.xml but i would
recommand to use tomee.xml and openejb:Resource/<id> or java:global names
> 2: What would the jndiName attribute of DataSource in log4j2.xml look like
> then?
>
> <Appenders>
> <JDBC name="databaseAppender" tableName="logging">
> <DataSource
jndiName="what-is-the-valid-jndi-name-of-LoggingDB"
> />
> <Column name="..." />
> <Column name="..." />
> </JDBC>
> </Appenders>
>
> 3: Do I need any further configuration in another file (like
> WEB_INF/web.xml, WEB_INF/resources.xml) ?
>
> I am running TomEE tomee-plus-1.7.2.
>
> I would appreciate any help,
> BR Jack
>
>
>
> --
> View this message in context:
http://tomee-openejb.979440.n4.nabble.com/log4j-2-JDBC-Appender-tp4676313.html
> Sent from the TomEE Users mailing list archive at Nabble.com.