Posts Tagged ‘syslog’

Recently, I started developing application on Adobe Android AIR.
But I wonder how I can debug my application on Android Phone.

I searched it, but many solutions can’t fit my case.
My requirements are
1 ) No USB connection
2 ) No Android SDK on my PC.
3 ) Can support on production mode ( No debug player )

In other words, The limitations move to outer enviroment from app and android phone.
And I want to control the outer environment.

My solution

Requirements

1 ) Need syslog server that can support TCP connetcion ( these are “rsyslog” or “syslog-ng” as I know )
2 ) TCPSyslogTarget as3 class ( can download on airxlib_log )
3 ) Wifi connection ( optional )
“optional” means .. I don’t think it is easy to make syslog server on the global network.

setup syslog server

The following config is a part of “rsyslog.conf”.

$ModLoad imtcp.so
$InputTCPServerRun 514
$AllowedSender TCP, 127.0.0.1, 192.168.1.0/24
:
local1.*                                                /var/log/air.log
setup logging functions on your source code
import com.coltware.airxlib.log.TCPSyslogTarget;

//  my syslog server's ip is "192.168.1.5". please change 

var syslog:TCPSyslogTarget = new TCPSyslogTarget("192.168.1.5");
syslog.program = "AdobeAIR";
syslog.filters = ["*"];
syslog.level = LogEventLevel.DEBUG;
syslog.facility = TCPSyslogTarget.LOG_LOCAL1;
syslog.includeCategory = true;
Log.addTarget(syslog);

use flex logging functions.

import mx.logging.ILogger;
import mx.logging.Log;

private static var log:ILogger = Log.getLogger("foofoo");
log.debug("mmmmmm....");

At first, I tried to use UDP connection. But I can’t. ( I don’t know the reason )

I made a class for syslog output for Adobe AIR.
Because I want to see logs using linux “tail” & “grep” command.

Download:
coltware_airxlib_log_r3.swc on code.google.com
Class name: UDPSyslogTarget.as

How to use UDPSyslogTarget
import com.coltware.airxlib.log.UDPSyslogTarget;

var syslog:UDPSyslogTarget = new UDPSyslogTarget("192.168.1.5");
syslog.facility = UDPSyslogTarget.LOG_LOCAL1;
syslog.program = "AdobeAIR";
syslog.filters = ["com.coltware.*"];
syslog.level = LogEventLevel.DEBUG;
syslog.includeCategory = true;
Log.addTarget(syslog);

Line 3. Set hostname and port(default is 514)
Line 4. Set facility
Line 5. Set program name

Other properties are same as TraceTarget class.

If you don’t know how to use TraceTarget, please see HERE.

output sample
Feb  1 23:46:01 [info] AdobeAIR: com.coltware.airxlib.db.DBManager create if not exists table .... invoked
Feb  1 23:46:02 [info] AdobeAIR: com.coltware.airxlib.db.DBManager TABLE CREATE OK
Feb  1 23:46:02 [debug] AdobeAIR: com.coltware.airxlib.db.DBManager [1/7] [SQL:] CREATE TABLE  IF NOT EXISTS project(
Feb  1 23:46:02 [debug] AdobeAIR: com.coltware.airxlib.db.DBManager [2/7] sysid INTEGER  PRIMARY KEY AUTOINCREMENT ,
Feb  1 23:46:02 [debug] AdobeAIR: com.coltware.airxlib.db.DBManager [3/7] title TEXT  NOT NULL ,
Feb  1 23:46:02 [debug] AdobeAIR: com.coltware.airxlib.db.DBManager [4/7] createdAt DATE  NOT NULL ,
Feb  1 23:46:02 [debug] AdobeAIR: com.coltware.airxlib.db.DBManager [5/7] updatedAt DATE  NOT NULL ,
Feb  1 23:46:02 [debug] AdobeAIR: com.coltware.airxlib.db.DBManager [6/7] createdBy INTEGER ,
Feb  1 23:46:02 [debug] AdobeAIR: com.coltware.airxlib.db.DBManager [7/7] updatedBy INTEGER );
rsyslog conf(sample)
$template air,"%timegenerated% [%syslogseverity-text%] %programname%: %msg%"
local1.*                                                /var/log/air.log;air
RSS
Add to Google
2017年2月
« 2月    
 1234
567891011
12131415161718
19202122232425
262728