Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I see (from your code) that your main objective is to filter the <a href="http://logging.apache.org/log4j/1.2/apidocs/index.html" rel="nofollow noreferrer">log entries/events</a> and then write the filtered logs to database. You have 2 options</p> <p><strong>Option 1:</strong> <em>Best and the right way to do. But you should be able to change the log4j config file that comes with tomcat</em></p> <p>If this is the case then the best way to do this is to use log4j's predefined extension points. In your case the tapping point is the <a href="http://logging.apache.org/log4j/1.2/apidocs/index.html" rel="nofollow noreferrer">Appender</a></p> <p>Log4j already comes with the <a href="http://logging.apache.org/log4j/companions/receivers/apidocs/org/apache/log4j/db/DBAppender.html" rel="nofollow noreferrer">DBAppender</a> that you might want to extend to filter the logs using your regular expression and then delegate the rest to <a href="http://logging.apache.org/log4j/companions/receivers/apidocs/org/apache/log4j/db/DBAppender.html" rel="nofollow noreferrer">DBAppender</a> as it is well tested. Below is an example on how to configure the custome appender</p> <blockquote> <p>log4j.rootLogger=DEBUG, S</p> <p>log4j.appender.S=com.gurock.smartinspect.log4j.MyCustomAppender</p> <p>log4j.appender.S.layout=org.apache.log4j.SimpleLayout</p> </blockquote> <p>I suggest you also look at using the <a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/AsyncAppender.html" rel="nofollow noreferrer">AsyncAppender</a> and DBAppender if you want to improve the performance.</p> <p><strong>Option 2:</strong> Fallback option if you doesn't have access to the tomcat's log4j config file</p> <p>Instead of writing your own file change listener, look <a href="https://stackoverflow.com/questions/494869/file-changed-listener-in-java">this post in SO</a>. Choose the one that best matches your needs. You are then only left with writing code for filtering and persisting the log in DB. You can use this <a href="http://www.javaworld.com/jw-01-1999/jw-01-step.html" rel="nofollow noreferrer">link as an example</a> for dealing with RandomAccessFile.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload