I need some suggestions in terms of SLF4J logging.
Currently, we are using SLF4J logging (log4j binding) for a our Java web app, which uses the simple ConsoleAppender. Our next step is researching for places where we can save the logs.
Our app processes about 100,000 messages per day. Each message generates about 60 -100 lines of logs. Our goal is to be able to quickly search and find failed messages (using an messageId) and identify causes for the failure.
My question is: which of the following is a good place to store our logs:
- File(s)
- DB
- Solr
Thanks.
There is no facility in the servlet specification providing you with a file system location for putting logs.
Hence the most robust, long term solution is to simply use java.util.logging (with the slf4j binding) and let the web container handle the logs generated.
You have about 10 million log entries pr day. This mean that you need to be careful with resource usage. Database communication is much more expensive than file access. I would suggest you profile the approaches to see if you can get the performance you need to consider anything else but flat files backed up on a nightly basis.
Consider switching away from log4j and using the logback implementation of the slf4j API Logback has an extensive list of appenders available.
I think perhaps your questions is more concerning making your logs searchable. The answer depends on what you're search for.
Update
As suggested by Sebastien there is also a Graylog2 appender for logback. Now available in Maven Central
Of course this will depend on having a graylog2 server installed.