-
1. Re: Asynchronous logging?
massios Mar 8, 2010 6:01 AM (in response to massios)Better yet, instead of using an MDB, since we are talking about an esb, sending a message to a logging service.
Nikos.
-
2. Re: Asynchronous logging?
edx Mar 8, 2010 6:30 AM (in response to massios)I have developed the appender that takes the messages from JBoss logging subsystem (log4j) and then writes them to database via configured pool of DB workers. If you are interested in such solution I can share it here.
Edward
-
3. Re: Asynchronous logging?
h.wolffenbuttel Mar 8, 2010 10:43 AM (in response to edx)Hi Edward,
Please do share
Regards,
Hans
-
4. Re: Asynchronous logging?
edx Mar 11, 2010 12:52 PM (in response to h.wolffenbuttel)Hello
The attached tar gzipped file (DbLogger.tar.gz) is a complete Eclipse (JBossTools 3.1) project directory
that you can extract somwhere and import to your projects workspace.
The project creates the Service Archive (.sar) that deploys two things:
1. (dblogger-ds.xml) Data Source that handles the conenctions to the instance of logging database
2. DbLoggingService as MBean in JBoss microcontainer.
The attached project configures Data Source to use mySQL database, other types of DB engines can be used (In the past I used PostgreSQL without problems).
The setup of the logging database is defined in files $ROOT/db-info/ directory,
where there is a sql database init script that creates logentries table
and there is also the project file dblogger.mwb for MySQL Workbench tool (DB model).
DbLoggingService is deployed as MBean for which the configuration is defined
in the file $ROOT/src/META-INF/jboss-service.xml which contains the JNDI name
definition that references the DataSource and also the dependency is defined for that datasource.
The DbLoggingService when started does also reconfiguration of JBoss log4j service
by adding the reference to the new Appender - EdxLogAppender.
The configuration of the new appender is in the file $ROOT/src/META-INF/log4j.xml
where three important startup parameters are set:
Timeout - value in miliseconds for waiting on new message in an internal Vector<>.
After that time the worker thread validates the connection to database.
DbWorkerNum - number of concurrent threads that do stroing log messages to database
MsgQueueDepth - the size of the message queue (Vector<>) used as FIFO for
feeding the workers.
The log4j.xml also defines the root of Category tree this appender is assigned.
The project defines (thanks to JBossTools plugin) the final product the deployment archive
DbLogger.sar that you can simply drop into JBossAS deploy directory.
In your ESB developments you can use the new logging facility by defining in your classes:
Logger log = Logger.getLogger( ctgry );
....
log.info("message");
where ctgry has to be started with root category defined in log4j.xml file.
Enjoy my work !
regards,
Edward
-
DbLogger.tar.gz 39.0 KB
-
-
5. Re: Asynchronous logging?
massios Mar 9, 2010 5:05 AM (in response to edx)Have a look at two more related projects I found:
-
6. Re: Asynchronous logging?
edx Mar 11, 2010 12:40 PM (in response to massios)Hello,
even in the std log4j you have the possibility of logging directly to database using JdbcAppender that is included in the base log4j package.
However the std. appender logs messages as text only (you have to provide the layout or the output message).
My appender logs messages into table and in separate columns the log level and source category is written.
This provides further possibility of intelligent analysing of the log data by searching for log entries of the particular importance (log level) and of the particular origin (category). Additionally it is deployed as the MBean service that you can access from any application from the JBoss runtime environment.
Regards,
Edward