"Gary Gregory" <garydgreg...@gmail.com> wrote on 2019-12-12 21:54:27:
> The more: > > https://github.com/apache/logging-log4j2/tree/release-2.x/log4j- > core/src/test/resources/org/apache/logging/log4j/core/appender/db/jdbc > > Gary Thanks for the examples, much appreciated. It confirmed that I was probably doing things correctly on the log4j front, at least. As it turns out, the problem was with Tomcat's documentation about how to set up a JNDI connection. They refer to a META-INF/context.xml file in the web-app directory, but in our case the context files are located in the ${CATALINA_OUT}/conf/Catalina/localhost directory and point to the locations where the web-app files can be found. Placing the <Resource .../> there got us rid of the error about the empty jdbc URL and driver name, at least. I'm almost there. I can select from the database with a slightly expanded variation on my previous Java class, so we are able to connect at least - now to figure out why the actual webapp is not logging anything... Should be easy enough to add a log4j JDBCAppender for my test-webapp. > On Thu, Dec 12, 2019 at 3:54 PM Gary Gregory <garydgreg...@gmail.com> wrote: > > > On Thu, Dec 12, 2019 at 9:55 AM Ralph Goers <ralph.go...@dslextreme.com> > > wrote: > > > >> I just looked at the JDBC unit tests and surprisingly didn’t see any that > >> use a configuration file. > >> > > > > Here is a 'fancy' example (the kind of stuff I use at work): > > > > > > https://github.com/apache/logging-log4j2/blob/release-2.x/log4j- > jdbc-dbcp2/src/test/resources/log4j2-jdbc-dbcp2.xml > > > > Here are some more: > > > > ;-) > > > > Gary This is what now remains of the configuration. ${CATALINA_OUT}/conf/Catalina/localhost/mywebapp_context.xml > >> >>>> --------------------- > >> >>>> <?xml version="1.0" encoding="utf-8"?> > >> >>>> <context docBase="/webapps/foo" path="/foo"> > >> >>>> <resource > >> >>>> name="jdbc/loggingtst" > >> >>>> auth="Container" > >> >>>> type="javax.sql.DataSource" > >> >>>> username="*****" > >> >>>> password="*****" > >> >>>> driverClassName="org.postgresql.Driver" > >> >>>> url="jdbc:postgresql://foobar:5432/logging-tst" > >> >>>> maxTotal="20" > >> >>>> maxIdle="10" > >> >>>> /> > >> >>>> </context> > >> >>>> > >> >>>> > >> >>>> WEB-INF/classes/log4j2.xml: > >> >>>> --------------------------- > >> >>>> <?xml version="1.0" encoding="UTF-8"?> > >> >>>> <Configuration status="WARN"> > >> >>>> ... > >> >>>> <Appenders> > >> >>>> ... > >> >>>> <JDBC name="DBAppender" tableName="logging.usage"> > >> >>>> <DataSource jndiName="java:/comp/env/jdbc/loggingtst"/> > >> >>>> <Column name="servername" pattern="%X{servername}"/> > >> >>>> <Column name="fex" pattern="%X{focexec}"/> > >> >>>> <Column name="parameters" pattern="%X{parameters}"/> > >> >>>> <Column name="username" pattern="%X{username}"/> > >> >>>> <Column name="duration" pattern="%X{duration}"/> > >> >>>> <Column name="user_agent" pattern="%X{user-agent}"/> > >> >>>> </JDBC> > >> >>>> </Appenders> > >> >>>> <Loggers> > >> >>>> ... > >> >>>> <Logger name="LogFilter" level="info" additivity="false"> > >> >>>> <AppenderRef ref="DBAppender"/> > >> >>>> </Logger> > >> >>>> > >> >>>> <Root level="error"> > >> >>>> <AppenderRef ref="sysout" /> > >> >>>> </Root> > >> >>>> </Loggers> > >> >>>> > >> >>>> </Configuration> > >> >>>> Alban Hertroys D: +31 (0)53 4 888 888 | T: +31 (0)53 4888 888 | E: alban.hertr...@apollovredestein.com Apollo Vredestein B.V.| Ir. E.L.C. Schiffstraat 370, 7547 RD Enschede, The Netherlands Chamber of Commerce number: 34223268 The information contained in this e-mail is intended solely for the use of the individual or entity to whom it is addressed. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or action in relation to the contents of this information is strictly prohibited and may be unlawful and request you to delete this message and any attachments and advise the sender by return e-mail. The confidentiality of this message is not warranted. Apollo Vredestein and its subsidiaries rule out any and every liability resulting from this or any other electronic transmission Please consider the environment before printing this e-mail