Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamp format for database auditing #77

Open
johno1985 opened this issue Jun 21, 2018 · 1 comment
Open

Timestamp format for database auditing #77

johno1985 opened this issue Jun 21, 2018 · 1 comment

Comments

@johno1985
Copy link

johno1985 commented Jun 21, 2018

I am trying to store the audit timestamp with the UTC timezone included in the database. I am using the following config

!Configuration
handlers:
- !org.audit4j.handler.db.DatabaseAuditHandler
    embedded: false
    db_driver: com.mysql.cj.jdbc.Driver
    db_url: jdbc:mysql://localhost:3306/launchbi_audit_local?serverTimezone=UTC
    db_user: ***
    db_password: ***
layout: 
  !org.audit4j.core.layout.SimpleLayout
    dateFormat: MM/dd/yyyy HH:mm:ss zzz

But this has no effect, the timestamp is stored without the timezone

I am using audit4j-core version 2.5.0 and audit4j-db version 2.5.0

@franck-benault
Copy link
Contributor

franck-benault commented Jun 23, 2018

Hello,

following to documentation http://audit4j.org/documentation/#layouts
the layout allows you to format the audit traces in console or file, not in database

I understand to need and you can a similar problem here
audit4j/audit4j-db#9

in fact for the audit in database there is not format possible
if you look at the code of AuditLogDaoImpl in Audit4j-db
everything is hard coded (timestamp and element).

please take also in account that this date event is store in a TIMESTAMP column
not a VARCHAR column

in the code of audit-db, you have
statement.setTimestamp(2, new Timestamp(event.getTimestamp().getTime()));

we shoud use the version with three parameters to force the time zone
example with time zone UTC
statement.setTimestamp(2, new Timestamp(event.getTimestamp().getTime()), Calendar.getInstance(TimeZone.getTimeZone("UTC"))));

please, look at your problem again and send a feed back with your need.

Regards Franck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants