Overview
Features
Download
Documentation
Community
Add-Ons & Services

How to log on daemon mode?

Please post support and help requests here.

How to log on daemon mode?

Postby mrunix » 19 Jun 2012, 04:36

Hi,

I use POCO library. I encounter a strange problem. my system is Linux for embedded PowerPC.

If I login to system first, I start my app like this:

# app &

I can got the log "app.log".

If I start my app like this:

# app --daemon

I can run the app, but cann't get any log, didn't create 'app.log' file.

QUESTION1: If I run my app by command line, how can I get the log?


If I start my app by "/etc/inittab", like this:

::sysinit:/etc/rc.d/rcS

I start my app in rcS script file. I can run my app, but the app cann't create "app.log" file.

QUESTION2: If I run my app by "/etc/inittab", how can I get the log?

Thank you!


--------------------------------------------------------------
LOG CONFIGURATION
--------------------------------------------------------------
logging.loggers.root.channel = splitter
logging.loggers.root.level = trace

logging.channels.splitter.class = SplitterChannel
logging.channels.splitter.channels = file

logging.channels.file.class = FileChannel
logging.channels.file.path = ${application.baseName}.log
logging.channels.file.pattern = %Y-%m-%d %H:%M:%S [%P:%I]:%q:%t
logging.channels.file.rotation = 1024K
logging.channels.file.archive = timestamp
logging.channels.file.purgeCount = 3
logging.channels.file.times = local
logging.loggers.file.level = information
mrunix
 
Posts: 4
Joined: 19 Jun 2012, 04:02

Re: How to log on daemon mode?

Postby alex » 19 Jun 2012, 13:26

Your application is probably writing the log, it's just not where you expect to find it. Either specify full path in the config file or chdir() in the application early during startup.
alex
 
Posts: 1086
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: How to log on daemon mode?

Postby mrunix » 20 Jun 2012, 02:54

Thanks, Alex. :D

How to set specify full path in the config file?

Like this:
logging.channels.file.path = /app/${application.baseName}.log
mrunix
 
Posts: 4
Joined: 19 Jun 2012, 04:02

Re: How to log on daemon mode?

Postby alex » 20 Jun 2012, 04:11

mrunix wrote:logging.channels.file.path = /app/${application.baseName}.log

Yes.
alex
 
Posts: 1086
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: How to log on daemon mode?

Postby mrunix » 20 Jun 2012, 04:44

alex wrote:
mrunix wrote:logging.channels.file.path = /app/${application.baseName}.log

Yes.


I have modified the config, but not work.

If I change chdir("/") to chdir("/app") in class ServerApplication, log can work.

I don't want to change class ServerApplication code, how can I get it work?

If I can change the working directory on daemon mode, I think the log can work.

Thanks.
mrunix
 
Posts: 4
Joined: 19 Jun 2012, 04:02

Re: How to log on daemon mode?

Postby alex » 20 Jun 2012, 14:18

I don't have your exact platform handy but I tried on ubuntu and had no problem doing it:

Code: Select all
parallels@ubuntu:~/trunk/Util/samples/SampleServer/bin/Linux/x86_64$ uname -a
Linux ubuntu 3.0.0-19-generic #33-Ubuntu SMP Thu Apr 19 19:05:14 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
parallels@ubuntu:~/trunk/Util/samples/SampleServer/bin/Linux/x86_64$ ls
SampleServer  SampleServer.properties
parallels@ubuntu:~/trunk/Util/samples/SampleServer/bin/Linux/x86_64$ cat SampleServer.properties
# This is a sample configuration file.
logging.loggers.root.channel = c1
logging.channels.c1.class = FileChannel
logging.channels.c1.path  = ${application.dir}${application.baseName}.log
logging.channels.c1.pattern = %s: [%p] %t
parallels@ubuntu:~/trunk/Util/samples/SampleServer/bin/Linux/x86_64$ ./SampleServer --daemon
parallels@ubuntu:~/trunk/Util/samples/SampleServer/bin/Linux/x86_64$ ls
SampleServer  SampleServer.log  SampleServer.properties
parallels@ubuntu:~/trunk/Util/samples/SampleServer/bin/Linux/x86_64$ cat SampleServer.log
Application: [Information] starting up
Application: [Information] busy doing nothing... 0d 00:00:05.003
alex
 
Posts: 1086
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: How to log on daemon mode?

Postby flomll » 18 Jul 2012, 09:44

I think you can detect the --daemon mode by the following code:

Code: Select all
application.runAsDaemon


Take a look at the http://pocoproject.org/slides/190-Applications.pdf on the bottom of the paper. It describe some points of the application framework.
flomll
 
Posts: 28
Joined: 18 May 2012, 08:58
Location: Austria


Return to Support

Who is online

Users browsing this forum: No registered users and 14 guests

cron