Feature ITW logging tasks implementation

Jiri Vanek jvanek at redhat.com
Fri Nov 1 07:39:32 PDT 2013

Hi all, before to much code is written. I would like to ask you to opinions about suggested approaches:

*Logging to file:*
Right now, i'm implementing  the logging of C part to file. Th implementation itelf is pretty 
simple. but from higher point, there are two crucial differences with several different approaches:
  - few notes notes
    - file logs are saved at {~/.config,$XDG_CONFIG_DIR}/icedtea-web/log without possibility to 
change this location... I think this is correct and I'm not going to change it (just going to 
higlight in ITW settings)
    - fielname is itw-numberOfMilissecondsSinceEpoch.log - Unless something against, I would like to 
change it to better name (date, time - sure - but in readable form)
    - java.stderr, java.stdout are no longer used

logging to file(s) approaches:
  - C side a and java side are each logging into own file in same directory with as similar name as 
possible, distinguished via some suffix PLUGIN/NETX
    - most easy to implement
    - different logs for C part and Java side (can be both positive and negative)
    - to have the name really same, name must be passed to java part similarly as next approach
  - C and java sides are sharing the file and each is writing on its own
    - also easy to implement, and surprisingly, even most dummy approaches [1] [2] (flushes are 
important) have  very good results (eg. messages are not mixed - Ihave palyed with similar 
approaches, process handling quite a lot))
    - name is passed to java side via parameter during lunching of jvm (as names of pipes are)
    - same log for C part and Java side (can be both positive and negative)
  - Combination of above. One shared file, and one file for each side. Probably the best, and now 
right under construction
  - C and java sides are sharing the file and only one part is responsible for writing.
   - this is probably just wrong idea, but there is no danger of conflict during writing into
     - C part is sending the messages via pipe (new or current one), and java side is logging them
       - advantage is usage of multithreaded logging on java side
     - Java part is sending the messages via pipe (new or current one), and C side is logging them
       - advantage can be in case of syslog(-ng) sytstem logger. The C api is much cleaner

*System logging:*
To be honest I got into dead end. Both me and pavel have tried several approaches, (abrt, syslog...) 
but none fit.
- I would like to log into syslog by default always and everything, and so if again somebody came 
and complain "it donot work", I will just tell him "look into well_knonw_location".
- Also for system admin should be logs of all users on some place, so he can look into logs on "well 
known location"
    - so logging should not  delay ITW run
    - multiline loggs must be allowed
    - logs should be automatically rolled
    - location should be something like /var/log/icedtea-web/$USER/rolled_logs where directory user 
should be 700 and fiels inside 600, owned by user
As from above, only classical syslog was close enough to fill the requirements, but he did not fill 
the last condition, nor multiline messages. Also the disadvantage of configured logging is.. well 
annoying, but survivable.
At the end I finished with syslog-ng. It looks like it is he is fulfilling all above, however it 
added  other:
   - it is still to new, nearly none system have it by default. It will never go into rhel<=7 .. not 
sure even about 8 :(
   - it is not widely , nor (haha) by default used/known

- Distors with packages can have syslog-ng as requirement, can start its daemon in post-install and 
can modify the syslog-ng properties file. (the config to reach above is not to simple). Not sure how 
to in non-packaging distros.
- all three parts itw-settings,javaws and plugin  should test the presence of (any) syslog, and to 
gray/disable  the system longing in case of it absence

I'm not syslog expert, so I could miss some feture... And I'm even less syslog-ng expert :) so any 
ideas welcome!

About the implementation itself, the C api for syslog is really simple. From java side is 
interesting pipes approach, small(one string in , nothing out)  JNI code (shared between java side 
and c side), or one of many existing libraries (but would be nice to avoid unnecessary dependence ), 
or tcp/udp message to specific port (how to find current syslog(-ng) port??)

As interesting approach of system logging may be just extension to file logging:
Lets expect that directory /var/log/icedtea-web/ with 777 permissions on icedtea-web exists (owened 
by root). Then We can have 700 permissions (owned y $USER)  directory $USER here, and log 600 
permissions files (owned y $USER) here in same way as we will do for "file logging". Stil the idea 
of ~.../log/ files should be kept. In this case I'm afraid of performance impact :(

*Logging settings"*
Last item I would like to bring up before first line of code, is setting.
Right now the settings are
  - global
   - debugging on/off  checkbook in itw-settings( or ICEDTEAPLUGIN_DEBUG or -verbose for javaws)
   - headers on/of itw settings checkbox
- which are affecting all  underlying outputs:
   - streams
   - file (only java implementation right now)
   - system (nothing implemented)

I'm thinking about individual settings (verbose and headers) of each stream.
In ideal world I would like to see:
   - streams - debug and headers off
   - file  - debug and headers off, and headers off when debug on
   - system (nothing implemented) -  debug and headers on

With possibility to switch each separately to on/of for debug, and on/of for headers (so change for 
checkbox to commbobox in itw-settings, but I have no idea how to deal with -verbose and 
ICEDTEA_PLUGIN for this granular settings)

Anyway. I'm not sure if this is worthy of effort (especially when I know that C headers generation 
are quite time consuming)

Any help from this dead ends welcomed!

best regards,

#include <stdio.h>
#include <time.h>

int main (int argc, char *argv[]) {
  FILE *fp;
  fp = fopen("shared","a+");
  while (1){
     struct timespec tim, tim2;
     tim.tv_sec  = 0;
     tim.tv_nsec = 50000000L;
     nanosleep(&tim , &tim2);
     fprintf(fp,"[c part] ccc ccc ccc ccc ccc [c end]\n");
import java.io.*;

public class writer {

public static void main(String[] args) throws Exception{
BufferedWriter out = null;
try {
     out = new BufferedWriter(new FileWriter("shared", true));
     while (true){
       out.write("[java side] jjj jjj jjj jjj jjj jjj [end of java side]\n");
} finally {

More information about the distro-pkg-dev mailing list