mercredi 26 août 2015

How to append logs from different users to the same text file in a SQLite table?

I am using log4j2 in order to have an audit trail file that stores logs for every action a user does.

All of these users are connected to an SQLite database table. Currently, all my logs are stored in a audit.log file but I want it to be stored in the database so that every user's logs are appended to the same audit.log file.

My log4j2.xml is as follows (which is basically the same as the official log4j site simple fileAppender example is):

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" name="MyApp" packages="">
  <Appenders>
    <File name="auditFile" fileName="logs/audit.log">
      <PatternLayout>
        <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
      </PatternLayout>
    </File>


  </Appenders>
  <Loggers>
    <Root level="error">
      <AppenderRef ref="auditFile"/>
    </Root>
    <Root level="info">
      <AppenderRef ref="auditFile"/>
    </Root>
  </Loggers>
</Configuration>

Aucun commentaire:

Enregistrer un commentaire