Enhancing JBoss AS 7 Database Access

Our application includes jboss logging. We currently use the "Rotating-file-handler" to register the entire file. This is defined in the standalone.xml jboss file. We also study the registration of some information in the logging database; for the sake of building indicators, etc.

Can anyone suggest some options that we can use here. Our ultimate goal is that since things are written to a file; we will intercept and record it in the database. We do not want to do this online, as this will be a blocking call.

+6
source share
2 answers

This link shows EXACTLY how to configure what I wanted. JBoss AS 7.0.1 has the function of supporting custom log handlers.

http://community.jboss.org/wiki/CustomLogHandlersOn701

+2
source

Use AsyncAppender and attach DBAppender to it.

Something like this for the asynchronous part:

<async-handler name="ASYNC"> <level name="DEBUG"/> <queue-length value="1024"/> <overflow-action value="BLOCK"/> <subhandlers> <handler name="CONSOLE"/> <!-- if you have these defined --> <handler name="FILE"/> <!-- if you have these defined --> <handler name="DB"/> </subhandlers> </async-handler> 

And then define DB as DBAppender (or JDBCAppender depending on what you installed).

 <log4j-appender name="DB" class="org.apache.log4j.jdbc.JDBCAppender"> <error-manager> <only-once/> </error-manager> <level name="INFO"/> <properties> <property name="URL">jdbc:postgresql://localhost:5432/data</property> <property name="driver">org.postgresql.Driver</property> <property name="user">admin</property> <property name="password">admin</property> </properties> <formatter> <pattern-formatter pattern="insert into Log values (current_timestamp,'%c', '%t','%p','%m')" /> </formatter> </log4j-appender> 
0
source

Source: https://habr.com/ru/post/900313/


All Articles