MicroLog Darius Katz Johan Karlsson Background Johan K. noticed - - PowerPoint PPT Presentation

microlog
SMART_READER_LITE
LIVE PREVIEW

MicroLog Darius Katz Johan Karlsson Background Johan K. noticed - - PowerPoint PPT Presentation

MicroLog Darius Katz Johan Karlsson Background Johan K. noticed the lack of a good logger for the Java ME environment. So he simply sat down and coded the first version of MicroLog and put it on SourceForge. The rest is history... Features


slide-1
SLIDE 1

MicroLog

Darius Katz Johan Karlsson

slide-2
SLIDE 2

Background

Johan K. noticed the lack of a good logger for the Java ME environment. So he simply sat down and coded the first version of MicroLog and put it on

  • SourceForge. The rest is history...
slide-3
SLIDE 3

Features overview

Log4j wannabe Log to the console Log to RMS (accessible with an included midlet) Log to file Log to Form Log over Bluetooth (coming real soon) Log over GPRS (coming soon) Flexible formatting Configurable

slide-4
SLIDE 4

Using MicroLog

//Init the logger Logger log = Logger.getLogger(); log.configure(properties); ... ... log.info(“Log this text”);

slide-5
SLIDE 5

Using MicroLog

//Init the logger Logger log = Logger.getLogger(); log.configure(properties); ... ... log.info(“Log this text”);

?

slide-6
SLIDE 6

Properties

Properties is a module in MicroLog which helps to set up the Logger. Example:

microlog.level=DEBUG microlog.appender=net.sf.microlog.appender.RecordStoreA... microlog.appender.RecordStoreAppender.maxLogEntries=20 microlog.formatter=net.sf.microlog.format.SimpleFormatter Line 2 in all its glory: microlog.appender=net.sf.microlog.appender.RecordStoreAppe nder;net.sf.microlog.appender.ConsoleAppender note: two Appenders

slide-7
SLIDE 7

Property sources

4 different sources today:

 Default values  Property file  Application properties (attributes)  Numbered application properties (attributes)

slide-8
SLIDE 8

Default values

Class is called DefaultValues Hardcoded in the class. Used if not changed by user in another property source. All “system properties” should be included. (In

  • ur case everything that MicroLog uses.)
slide-9
SLIDE 9

Property file

Class is called PropertyFile A file named microlog.properties in the midlet- root contains the properties/values. User can change the default values. User can add own values. Example:

microlog.level=DEBUG microlog.appender=net.sf.microlog.appender.RecordStoreA... microlog.appender.RecordStoreAppender.maxLogEntries=20 microlog.formatter=net.sf.microlog.format.SimpleFormatter

slide-10
SLIDE 10

Application properties

Class is called AppProperty Properties are added in the jad-file or in the manifest-file as usual attributes (property:value) User can change the default values. User can override the values in the properties file. User can not add own values.

slide-11
SLIDE 11

Numbered application props

Class is called NumberedAppProperty Properties are added in the jad-file or in the manifest-file as attributes in a special way:

 AppProperty_1 : MyProperty=MyValue  AppProperty_2 : MyOtherProperty=MyOtherValue  AppProperty_3 : SomeOtherProperty=SomeOtherValue

User can change the default values. User can override the values in the properties file and the values set in application properties. User can add own values.

slide-12
SLIDE 12

Repetition

Values are read in the following order:

1.DefaultValues 2.PropertyFile 3.AppProperty 4.NumberedAppProperty

Each new level overrides the same properties in the previous levels.

slide-13
SLIDE 13

Using Properties

//Create a new properties in the MIDlet class Properties properties = new Properties(this); ... ... myString = (String)properties.get(“MyProperty”); myString = properties.getString(“MyProperty”); ... this is the midlet

slide-14
SLIDE 14

Finally

Use Properties in your own mobile applications

slide-15
SLIDE 15

Using MicroLog

//Init the logger Logger log = Logger.getLogger(); log.configure(properties); ... ... log.info(“Log this text”);

?

X

slide-16
SLIDE 16

Using MicroLog, the final cut

//Init properties Properties properties = new Properties(this); //Init the logger Logger log = Logger.getLogger(); log.configure(properties); ... ... log.info(“Log this text”); log.error(“Log this error”);

slide-17
SLIDE 17

MicroLog building blocks

Appenders (“output channels”)

 ConsoleAppender (to the console)  FileAppender (to a file via JSR75, FileConnection API)  RecordStoreAppender (to the RMS)  FormAppender (to a form)  BluetoothAppender (under development)  GPRSAppender (to be developed)  more...

Formatters (“looks of the output”)

 SimpleFormatter (predefined, simple)  ConfigurableFormatter (under development)  more?

slide-18
SLIDE 18

Popular Appenders

ConsoleAppender

 Used in emulators  Used in P900/P910 with a utility

RecordStoreAppender

 Used in all mobiles  Comes with a MIDlet that views the logs

BluetoothAppender

 Send logs to the PC  Used with mobiles that support Bluetooth

slide-19
SLIDE 19

How to add to your project

Download and unpack Copy source-code to your project

 (JAR-file in the future when the API is finalized)  copy microlog.properties if needed

Set properties

 in application properties OR  in microlog.properties file (important: correct CRLF)

Add MIDlet to suite

 RecordStoreLogViewer (if needed)

Add init code

 in MIDlet constructor OR  in MIDlet startUp() method

Use

 don't abuse (might slow down)

slide-20
SLIDE 20

Demo

Live on stage

slide-21
SLIDE 21

How to add to your project

Download and unpack Copy source-code to your project

 (JAR-file in the future when the API is finalized)  copy microlog.properties if needed

Set properties

 in application properties OR  in microlog.properties file (important: correct CRLF)

Add MIDlet to suite

 RecordStoreLogViewer (if needed)

Add init code

 in MIDlet constructor OR  in MIDlet startUp() method

Use

 don't abuse (might slow down)

slide-22
SLIDE 22

Code help wanted

BluetoothAppender (BT-expert needed) GprsAppender More flexible Formatter

 perhaps “%d %t %m” etc.

Get hold of stacktrace in exception Improve read of microlog.properties file Anything else you'd like Non-coding things:

 Design homepage  Tutorials  FAQ  Manuals

slide-23
SLIDE 23

Links

MicroLog homepage:

http://microlog.sourceforge.net

Project page on SourceForge:

http://sf.net/projects/microlog

slide-24
SLIDE 24

Thank you for listening