enonic / xp

Enonic XP
https://enonic.com
GNU General Public License v3.0
202 stars 34 forks source link

Log application start, stop, install and uninstall actions #6858

Closed ComLock closed 5 years ago

ComLock commented 5 years ago

At a customer the cronJob app often gets state STOPPED. I have looked trough all the access log on the 6 cluster nodes and found no entry for application stop. I think this is an important thing to log. Is it logged? Just no one has ever clicked stop? If not please add logging of an app beeing stopped, and who did it.

ComLock commented 5 years ago

I can log when an app is stopped using __.disposer https://xp.readthedocs.io/en/stable/developer/ssjs/main.html

But the context is always the same

{
    "branch": "draft",
    "repository": "cms-repo",
    "authInfo": {
        "principals": [
            "user:system:anonymous",
            "role:system.everyone"
        ]
    }
}

main.js

var contextLib = require('/lib/xp/context');

log.info('Application ' + app.name + ' started in context ' + JSON.stringify(contextLib.get(), null, 4));

__.disposer(function() {
    log.info('Application ' + app.name + ' stopped in context ' + JSON.stringify(contextLib.get(), null, 4));
});
ComLock commented 5 years ago

The request log does not even say which app was started

alansemenov commented 5 years ago

We don't log application start either, not sure where this was coming from in your logs. I've now added logging for start, stop, install and uninstall.