Re: logging to file in gtkmm



I'm sorry to bother again, I'm going with syslog which works pretty good but seems to write
to /var/log/syslog only and I cannot find a way to write to a dedicated file.
I'm using the following code:

// gcc giuspexample.c -o giuspexample
#include <syslog.h>

int  main()
{
    setlogmask(LOG_UPTO (LOG_NOTICE));
   
    openlog("atm", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL0);
   
    syslog(LOG_NOTICE, "Program started by User %d", getuid ());
    syslog(LOG_INFO, "A tree falls in a forest");
   
    closelog();
    return 0;
}

I followed the instructions on http://www.codealias.info/technotes/syslog_simple_example on how to change the destination filepath

echo "local0.*  /var/log/mylog" >> /etc/syslog.conf

but does not write on /var/log/mylog (still on /var/log/syslog).
I'm on (L)ubuntu 12.04.

Many thanks.



On Fri, Jun 8, 2012 at 11:23 PM, Florian Philipp <lists binarywings net> wrote:
Am 08.06.2012 09:55, schrieb Giuseppe Penone:
> Hi,
> I need to log to file but I'm not an expert in it, I would like to
> control the number of days logged to do not fill up the disk.
> Is there an adviced way to do it in gtkmm?
> Thanks.
>

There is a logging stream in gtkmm-utils [1]. It doesn't support
truncating the files though. Depending on your application, syslog and
logrotate might be a better approach.

Alternatively, do some timeout logic (using [2]) to change the log file
every day and remove old ones.

[1] http://code.google.com/p/gtkmm-utils/
[2]
http://developer.gnome.org/glibmm/unstable/classGlib_1_1SignalTimeout.html

Regards,
Florian Philipp


_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
https://mail.gnome.org/mailman/listinfo/gtkmm-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]