Using logger in client


I’m using the logger (system.util.getLogger) to allow the user to trace what’s happening. This functionality should be toggle on or off by the user.
Currently, gateway scripts are logging some things like start up, using a project script. This log appears correctly in the gateway Status/Diagnostics/Logs.
Now I want to use the same script but in the client (for exemple when user click on a button). The problem here is the log don’t show in the gateway log. I’ve seen we can get it in the Help/Diagnostics of the Designer, but this log only what’s happening on preview mode.
Is there a way to show these logs from gateway or directly the client ?

Thank you.

I’m also very interested in this, but so far, I don’t think it’s possible to log directly on the server from the client.

What I did before was making a custom logging function in the global scripts. That function checked whether is was being executed from the server or a client (you can do that by querying some system client tags, f.e. the current logged in user). If it was executed from the server, it would log immediately. If it was executed from the client, it would send a message using the system.util.sendMessage call, and log it to the server.

It works without problems, but it’s a bit cumbersome to set up for something that should be available by default IMO (you need to import a script, set up the correct message listener, change existing logging, …)

It’s all about context… You have three distinct areas, Client, Designer, and Gateway. The logger will work in the same way in all contexts, but will log within that session. For anything in the gateway context, as you know, it will go to the gateway logs. Clients will go the the clients, etc.

For data I need to be able to remotely log and debug, I often use the database and send the logs via SF to the DB. That way I can remotely monitor and report on the log data I care about.

The client logs are viewable at runtime from Help->Diagnostics. I would strongly encourage using the client-side logs as much as possible – polluting the gateway log with lots of clients’ messages seems like trouble to me.

1 Like

@pturmel --> oh yeah I forgot about it in the client, but I hide the menu bar (still the shortcut is working). That would be usefull if I could get maybe the console tab alone. I find the Log Viewer unfriendly for a “simple” user. And it will not be lots of logs since it should only be one or two users at the time for some precise windows.
edit: in fact, they want the full diagnostic views but in a full screen called inside the client, is there a way to do it ?

@ryanjmclaughlin --> using the database could be a pretty good solution, it would just need a specific window to show (probably a popup to continue manipulating meanwhile) and some other stuff.

@Sanderd17 --> Well, that’s pretty barbaric :stuck_out_tongue: I was on the idea it could be done natively too.

Adding to what @pturmel said, you can bring the diagnostics window up with CRTL+SHIFT+F7



I wrote a module to append a database connection as a logging target. It works really well until the database is down and causing all the error messages. Then, stuff goes down hill really, really fast.