ShaDooW
ShaDooW

Reputation: 483

Install4j: how to enable logging with timestamp

So far by default, the Installation/ update log file shows the logs in the following format:

[log_level] class/action [id]: log_message

is it possible to add the "time" with each log entry?

Upvotes: 2

Views: 269

Answers (1)

Ingo Kegel
Ingo Kegel

Reputation: 48070

It's not possible to do this for each line in the log file, but you can print a time stamp each time an action is executed. To do that, add a "Run script" action to the "Startup" node with the script:

context.addInstallerEventListener(new InstallerEventListener() {
    @Override
    public void installerEvent(InstallerEvent event) {
        if (event.getType() == EventType.BEFORE_EXECUTE_ACTION) {
            Util.logError(event.getSource(), "Started action at " +
              DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM)
               .format(new Date()));
        }
    }
});

Upvotes: 1

Related Questions