# Setting Log File Types and Parameters in Java

> As explained in the persistent database recovery page the eXtremeDB runtime uses the transaction log file to perform recovery automatically in the case of a prior application crash. The Persistent Database I/O page explains the different log types and how to choose the appropriate type for different application profiles. The manner in which transactions are written to the log is determined by the transaction commit policy. The following sections explain how to set the log type and commit policy in C applications.

> ## Log type

> The log type is specified in the `Database.Parameters.LogType`. For example:

>         Database.Parameters parameters = new Database.Parameters();
>         ...

>         // Set log file type
>         parameters.logType = Database.LogType.UndoLog;

> ## Commit Policy

> As explained in the Persistent Database I/O page, eXtremeDB offers four distinct commit policy options for log types `RedoLog` and `UndoLog`. The commit policy is set in parameter `Database.Parameters.DefaultCommitPolicy` before calling Database method `open()`.

> The `NoSync` policy causes all transactions to be held in the cache until the application explicitly forces the cache to be flushed to the media with the Connection method `diskFlush()`.

> There are additional parameters to consider for the `RedoLog` log type. For the `Delayed` policy, the database disk manager keeps the transaction in memory until a specified percentage of the log file size is reached. The threshold values `Database.Parameters.RedoLogLimit`, `Database.Parameters.DelayedCommitThreshold` and `Database.Parameters.MaxDelayedTransactions` can be specified in the parameters passed to Database method `open()`. By default, the threshold is set to be a half of the available page pool size.

> For example, the following code snippet demonstrates setting the log type, commit policy and parameters:

>         Database.Parameters parameters = new Database.Parameters();
>         ...
>         parameters.logType = Database.LogType.RedoLog;
>         parameters.defaultCommitPolicy = Database.CommitPolicy.Delayed;
>         parameters.maxDelayedTransactions = 100;
>         ...

>         db.open("operations-db", parameters, DATABASE_SIZE);