Home Contact Download
LSC logo
Open source connector to synchronize identities to a LDAP directory from any data source including any database with a JDBC connector, another LDAP server or flat files ...
Download  |  Read more...  |  Get started!

Managing output format through Log4j

LSC uses the Log4j library to output various messages. You can enable multiple outputs with different format by simply changing the configuration in the etc/log4j.properties file.

Outputting the synchronization in CSV files

In LSC you have a specific layout to log every action in a CSV file.

This uses the log4j logs, so you have to declare this in the etc/log4j.properties file.

Here is a small example :

log4j.appender.LSC_CSV = org.apache.log4j.FileAppender
log4j.appender.LSC_CSV.file= /tmp/csv.log
log4j.appender.LSC_CSV.layout = org.interldap.lsc.utils.log4j.csv.CsvLayout
log4j.appender.LSC_CSV.layout.logOperation = create,update
log4j.appender.LSC_CSV.layout.attrs = \
    dn;uid;sn;givenName;description;cn;mail;;objectClass;userAccountControl
log4j.appender.LSC_CSV.layout.separator = ;
log4j.appender.LSC_CSV.layout.outputHeader = true
log4j.appender.LSC_CSV.layout.taskNames = MyTask

Use the org.apache.log4j.FileAppender or any subclass as an appender. Specify the path to the csv file you want to write to in log4j.appender.LSC_CSV.file. Use the org.interldap.lsc.utils.log4j.csv.CsvLayout for the layout

This specific layout has 4 options :

  1. logOperation : which actions you want to log (create, update, delete, modrdn). You can specify multiple actions by grouping them with commas ','.
  2. separator : which separator you want to use in the output (default a semi-colon ;)
  3. attrs : which attributes you want to write. The attributes MUST be separated by the property separator. You can specifiy empty columns if you want to.
  4. outputHeader : true or false. This will print the “attrs” option before outputting any data lines - thus your CSV file can have a standard header.
  5. taskNames : a coma separated list of tasks you want to output in CSV

Note: The special attribute name “dn” can be used to output the entry's distinguishedName.

You can specify multiple loggers using the same layout and different options. For example, you can specify 4 loggers, one for each actions.

Outputting the synchronization in LDIF files

In LSC you have a specific layout to log every action in a LDIF file.

This uses the log4j logs, so you have to declare this in the log4j.properties file.

Here is a small example:

log4j.appender.LSC_LDIF = org.apache.log4j.FileAppender
log4j.appender.LSC_LDIF.file= /tmp/csv.log
log4j.appender.LSC_LDIF.layout = org.lsc.utils.LocalizedJndiModificationsLayout
log4j.appender.LSC_LDIF.layout.onlyLdif = true