logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <ralph.go...@dslextreme.com>
Subject Re: Custom Log Messages that get forwarded to a database (JPA or JDBC)
Date Fri, 29 Nov 2013 06:37:09 GMT
While I understand your desire to route different classes of events to different destinations,
and I am sure Log4j 2 could be used to implement your proposal I still have reservations about

First, to implement what you are suggesting you can create various Messages such as a URLMessage,
EnvironmentMessage, PerformanceMessage, etc.  You could do

URLMessage msg = new URLMessage(url, status);

or you could create the Facade you propose which does the above under the covers. However,
instead of logger.info you would want to use logger.log so you could set the FQCN to your
class name.

My reservations stem from your mention that the Facade would parse the calls and store the
events into the appropriate database table. That is something you do not want to do. Instead,
that should be handled by your logging configuration, which you could do by filtering based
on the specific Message implementation that was included in the event.  One of the main purposes
of a logging framework is to insulate the application from what actually happens to the events
that it generates.


On Nov 22, 2013, at 5:13 PM, Christian Schneider <cschneiderpublic@gmail.com> wrote:

> Hi, our application runs on several nodes and sometimes there are some long
> running processes.
> During this processes we collect logs of different types.
> For example:
> * Current Env. information (like IP-Address, OS Name, ...)
> * Urls and their statuscodes,
> * Erros (Stacktraces) thrown during the process
> * Some logging of execution times of sub tasks
> * Some counts of different events
> * Information about loaded plugins from the classpath
> and stuff like that.
> At the end we need to browse through this data (e.g. with a WebUI from a
> database) to react on the things that may happened during the process.
> Because the types so different, it would be nice to have an own logging
> facade. Something like this:
> interface ProcessLoggingFacade {
>    public void info(String ipAddress, OS osType, ...);
>    public void info(Url url, int statuscode);
>    public void error(String msg, Throwable e);
>    // ....
> }
> The impl. of this facade should parse all calls and store them into
> different tables of a remote database.
> Do you think this is a good approach and it is possible with log4j?
> Thanks,
> Best Regards,
> Christian.

To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

View raw message